ssh免密码,密钥登录

[root@Linux-node1 ~]$ ssh-keygen -t dsa #生成密钥

Generating public/private dsa key pair.

Enter file in which to save the key (/home/root/.ssh/id_dsa):  #默认回车一路

/home/root/.ssh/id_dsa already exists.

Overwrite (y/n)? y

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/root/.ssh/id_dsa. #这是钥匙

Your public key has been saved in /home/root/.ssh/id_dsa.pub. #这是锁

The key fingerprint is:

39:6f:d8:42:61:d7:c3:f9:4b:e7:fb:b0:af:52:cd:59 root@nfs-server

The key's randomart image is:

+--[ DSA 1024]----+

|                |

|          o .  |

|        o . =    |

|      . +  o  E|

|        S    oo+|

|      . =  ..=o|

|        o +  .o .|

|        o  .  o.|

|            .o++|

+-----------------+

[root@nfs-server ~]$ ssh-copy-id -i ~/.ssh/id_dsa.pub [email protected]  #公钥分发给其他服务器

[email protected]'s password:

Now try logging into the machine, with "ssh '[email protected]'", and check in:

.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

[root@nfs-server ~]$ ssh -p22 [email protected] #使用root用户登录node2节点服务器

Last login: Wed Aug 10 17:59:02 2016 from 192.168.90.201

[root@linux-node2 ~]$ #成功登录

你可能感兴趣的:(ssh免密码,密钥登录)