4

I am having difficulty SSH'ing git commands (e.g. git pull) without having to GitHub enter username and passcode.

I can SSH into my Dreamhost server and manually run git pull. I then have to enter my GitHub username and passcode. This is fine and dandy but I'd like to run git pull WITHOUT having to enter my GitHub credentials every time.

Found out that I needed to add SSH keys but the server still asks for GitHub credentials.

I did the following:

  1. SSH'd into Dreamhost shared server using PuTTy

  2. Did the following:

$ ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/funkyserver/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):   <-- I left this empty

Enter same passphrase again:   <-- I left this empty

Your identification has been saved in /home/funkyserver/.ssh/id_rsa.

Your public key has been saved in /home/funkyserver/.ssh/id_rsa.pub.

The key fingerprint is:

12:c3:12d:88:01:pp:12:b5:ca:33:8g:1q:64:ce:4a:81 funkyserver@wonkyninja  <-- wonkyninja is Dreamhost's server name and this fingerprint is fake

The key's randomart image is:  <-- I left this part out on purpose
  1. Copied the /.ssh/id_rsa.pub key and added it under the 'Deploy Keys' section @ GitHub.com
  2. Back on the Dreamhost server, I SSH'd into the directory with the git repo (e.g. /home/funkyserver/mysite)
  3. Ran git pull and it still asks me to enter GitHub credentials

What am I doing wrong with the SSH keys? Did I not generate them correctly? Did I not add them to GitHub properly?

Please help.

vvns
  • 3,548
  • 3
  • 41
  • 57
JsusSalv
  • 517
  • 1
  • 8
  • 22
  • Possible duplicate of [Git push requires username and password](http://stackoverflow.com/questions/6565357/git-push-requires-username-and-password/18348125#18348125) and [Git keeps prompting me for password](http://stackoverflow.com/questions/7773181/git-keeps-prompting-me-for-password). –  Aug 29 '13 at 02:17

1 Answers1

9

Try doing git remote -v.

If your remotes are prefixed with https:// a password will be asked.

You can change over to the ssh protocol with git remote set-url origin git@github.com:username/repo.git

There is more information in this question and on Github

Community
  • 1
  • 1
  • Brilliant!!! That worked. I changed it from 'https://' to 'git@github.com:username/reponame.git' as you noted above. Now I don't need to enter credentials every time. It said it couldn't verify the GitHub keys but I elected 'yes' anyway and now the Dreamhost server recognizes GitHub.com as a known host. – JsusSalv Aug 29 '13 at 01:16