Is there a way to generate a certificate or such so that my prod server can pull from my github repo without me authenticating every single time?
This is what Deploy Keys are for.
That help article explains what deployment authentication methods GitHub supports and gives some pointers to help decide between them.
In my limited experience, deployment SSH keys are probably the simplest to set up.
You can create an access token and use it as username (without password).
Once you have your access token clone the repository:
git clone https://<your-access-token>@github.com/username/repo.git
Then you can pull without authenticating every single time.
This is the simplest method but will store the token plain text into .git/config To improve security you can setup password caching and clone as usual https:
git clone https://github.com/username/repo.git
If you want remove access of server to repository, just delete the access token in your application settings.
I also prefer to use https than ssh on deploy environments. Some times we don't have enough access privileges to handle with ssh, but https access to github is available even on cheaper hosting services.
git clone https://<your-user-name>:<your-access-token>@github.com/username/repo.git
if your user name is not the same as the repos. –
Defiance git clone https://<your-access-token>@github.com/username/repo.git
on private repository as well. Looks like the user is not required. –
Bravura This is what Deploy Keys are for.
That help article explains what deployment authentication methods GitHub supports and gives some pointers to help decide between them.
In my limited experience, deployment SSH keys are probably the simplest to set up.
generate ssh key
cd ~/.ssh
ssh-keygen -t rsa -C "your-email-address"
touch config
paste in config
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/YOUR_KEY
paste public key to github deployment key settings
cat YOUR_KEY.pub
set remote from http to ssh
git remote set-url origin ssh://[email protected]/USERNAME/REPOSITORY.git
set-url origin ssh
was the missing part on my side. Thanks. –
Slake I think this can be done by using credential caching and using the .netrc file. Please Check This
Instead of having to clone a repository if the repository is already in place it's simple as:
git remote set-url origin https://<githubToken>@github.com/<github user name>/<repository name>
© 2022 - 2024 — McMap. All rights reserved.