SSH Auto Login

On the client that requires to login to the remote, execute the following command to generate the public and private keys.

[root@localhost ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
3e:b1:6d:44:73:e6:ca:af:3c:06:48:f1:f2:c1:5a:b6 root@localhost.localdomain

append the public key to the remote server
on the client
cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwA3AQEAsr8DueNT........... root@localhost.localdomain

on the server
echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwA3AQEAsr8DueNT........... root@localhost.localdomain"
>> ~/.ssh/authorized_keys2

You may need to change root@localhost.localdomain to suit your need.

Leave a Reply