Tuesday, May 13, 2008

Passwordless ssh

1. generate keys
localhost$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/localuser/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/localuser/.ssh/id_rsa.
Your public key has been saved in /home/localuser/.ssh/id_rsa.pub.
The key fingerprint is:
1d:75:9f:51:3d:16:40:85:7c:aa:17:84:38:2
c:4e:6b localuser@localhost

2. copy public key to remote host
localhost$ cat ~/.ssh/id_rsa.pub | ssh remoteuser@remotehost "cat - >> ~/.ssh/authorized_keys"

3. now test
localhost$ ssh remoteuser@remotehost

remotehost$



Troubleshooting
1. ensure the following on the remote host

chmod 700 /home/remoteuser
chmod 700 /home/remoteuser/.ssh
chmod 644 /home/remoteuser/.ssh/authorized_keys

In /etc/ssh/sshd_config

RSAAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

No comments: