Friday, 13 April 2012

Passwordless SSH Authentication

[root@station1 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):  (dont type anyting just press enter everywhere)
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:
d8:98:4b:01:c2:dc:95:be:17:c3:5a:23:02:dc:06:00 root@station1.example.com
The key's randomart image is:
+--[ RSA 2048]----+
|E=o+....         |
|  =.+..          |
|   o ...         |
|    . o**        |
|     .==S+       |
|     .o..        |
|      ..         |
|                 |
|                 |
+-----------------+
[root@station1 ~]#
[root@station1 ~]# scp -r /root/.ssh/id_rsa.pub 10.65.62.32:/root/.ssh/id_rsa.pub.server
[root@station1 ~]# ssh 10.65.62.32
Password:

[root@station2 ~]# cat /root/.ssh/id_rsa.pub.server >> /root/.ssh/authorized_keys
[root@station2 ~]# vim /etc/ssh/sshd_config

  49 AuthorizedKeysFile      .ssh/authorized_keys

[root@station2 ~]# service sshd restart
[root@station2 ~]# exit
[root@station1 ~]# ssh 10.65.62.32
now with out asking password it will login to station2
[root@station2 ~]#

No comments:

Post a Comment