views:

4772

answers:

3

I set a passphrase when creating a new SSH key on my laptop. But, as I realise now, this is quite a PITA when you are trying to commit(git,svn) to a remote location over SSH many times in an hour.

One way I can think of is, delete my SSH keys and create new. Is there a way to remove the passphrase, while still keeping the same keys?

Answer:

In short, follow these steps:

$ ssh-agent bash

$ ssh-add ~/.ssh/id_rsa

$ ssh username@remote

Voila!

+1  A: 

Take a look at this passwordless SSH tutorial.

William Keller
+14  A: 

Short answer:

$ ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]

However, you might want to consider using ssh-agent, which can cache the passphrase for a time.

The latest versions of gpg-agent also support the protocol that is used by ssh-agent.

Torsten Marek
+1 for answering the question, and mental +1 for offering a superior solution to the problem.
Eddie Parker
A: 

You might want to add the following to your .bash_profile (or equivalent), which starts ssh-agent on login.

if [ -f ~/.agent.env ] ; then
    . ~/.agent.env > /dev/null
if ! kill -0 $SSH_AGENT_PID > /dev/null 2>&1; then
    echo "Stale agent file found. Spawning new agent… "
    eval `ssh-agent | tee ~/.agent.env`
    ssh-add
fi 
else
    echo "Starting ssh-agent"
    eval `ssh-agent | tee ~/.agent.env`
    ssh-add
fi

On some Linux distros (Ubuntu, Debian) you can use:

ssh-copy-id -i ~/.ssh/id_dsa.pub username@host

This will copy the generated id to a remote machine and add it to the remote keychain.

You can read more here and here.

mlambie
Don't modern distribution start an ssh-agent out of the box?
Troels Arvin