Pull from github without authentication every time

41,620

Solution 1

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.

Solution 2

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.

Solution 3

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

Solution 4

I think this can be done by using credential caching and using the .netrc file. Please Check This

Share:
41,620
Matt Welander
Author by

Matt Welander

Updated on July 09, 2022

Comments

  • Matt Welander
    Matt Welander almost 2 years

    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?