Linux passwordless ssh configuration

10 May

Generate ssh keys

[user@mgmt-box ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Created directory '/home/user/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/
The key fingerprint is:

Make .ssh directory on target host and copy generated public key into authorized_keys file

[user@mgmt-box ~]$ ssh rac-nodea 'mkdir -p .ssh'
user@rac-nodea's password:
[user@mgmt-box ~]$ cat .ssh/  | ssh rac-nodea 'cat >> .ssh/authorized_keys'
user@rac-nodea's password:
[user@mgmt-box ~]$ ssh rac-nodea 'chmod 700 .ssh; chmod 640 .ssh/authorized_keys'

Test passwordless connection

[user@mgmt-box ~]$ ssh rac-nodea
[user@rac-nodea ~]$

* The email will not be published on the website.