40

Every time I try to push anything to GitHub it asks me the address git@github.com:... and after that it wants the passphrase. Is there a way to automate this?

I am using Linux Ubuntu.

jnbdz
  • 4,863
  • 9
  • 51
  • 93
  • give us a few more infos: did you add github as remote? how do you exactly call `git push`? what's the exact output of the command? – eckes May 24 '11 at 06:04

3 Answers3

85

You can use ssh-agent to remember your passphrase (Gnome automatically runs this for you, normally...).

$ ssh-agent bash
$ ssh-add 
Enter passphrase for /home/elyobo/.ssh/id_rsa: 
Identity added: /home/elyobo/.ssh/id_rsa (/home/elyobo/.ssh/id_rsa)

From now on, from within the terminal that you run this, your pass phrase will be remembered.

Ideally you'd get it working automatically, so all shells running within gnome would work; check out Gnome Keyring.

El Yobo
  • 14,823
  • 5
  • 60
  • 78
  • I am not using any GUI. Just the terminal. I am using Ubuntu server. Your code actually works. Now the problem is that I need to re-type: git@github.com:username/... .git Is there a solution? – jnbdz May 24 '11 at 07:02
  • 2
    Ah, yes, with a server you will need to do the above. However, if you can access the repository with the key on your local machine you can still use `ssh -A` to forward the key (look up the man page) and use the ssh-agent on your desktop to handle the passphrase, it will save you some effort (and work in multiple terminals if you have them open). I would have thought you can just run `git push` or something, but I'm not very familiar with git, just SSH :) – El Yobo May 24 '11 at 07:07
  • Check out ssh agent forwarding, there's no reason to manage keys across multiple systems you're ssh-ing into. – Tekkub May 24 '11 at 08:41
1

It is because you are using HTTPS (something like https://github.com/felipelalli/private.git) instead SSH (something like git@github.com:felipelalli/private.git).

If need to clone the SSH and then authorize your machine following theses steps: https://help.github.com/articles/generating-ssh-keys

Felipe
  • 16,649
  • 11
  • 68
  • 92
0

Another way to use the ssh-agent and ssh-add commands to add your private identity to the authentication agent.

$ eval "$(ssh-agent -s)"
Agent pid 1174
$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /home/james/.ssh/id_rsa: 
Identity added: /home/james/.ssh/id_rsa (/home/james/.ssh/id_rsa)
James
  • 4,599
  • 2
  • 19
  • 27