Friday, 6 August 2010

passwordless ssh

On the local machine, generate a key-pair. Then append the public key to the remote list of authorised hosts. DSA is old, RSA is new. Ho hum. rsa from now on.

The pairs are stored in

~/.ssh/id_rsa (id key)

OR

~/.ssh/id_rsa.pub (public key)

So: generate with

$ ssh-keygen -t rsa

Append the public key to the remote host with the command:

$ ssh-copy-id -i ~/.ssh/id_rsa.pub username@remoteaddress

That should append to ~/.ssh/authorized_keys


Check the remote machine /etc/ssh/sshd_config has,

RSAAuthentication yes
PubkeyAuthentication yes

Restart the server if needed:

/etc/init.d ssh restart


This may be needed in .bash-profile: http://mah.everybody.org/docs/ssh

SSHAGENT=/usr/bin/ssh-agent
SSHAGENTARGS="-s"
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then
eval `$SSHAGENT $SSHAGENTARGS`
trap "kill $SSH_AGENT_PID" 0
fi


Now configure ssh-agent to provide the passphrase.

$ ssh-add ~/.ssh/id_rsa

No comments:

Post a Comment