SSH互信

  1. SSH互信

SSH互信

在母机上

[root@lyucan ~]# ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
Generating public/private rsa key pair.
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
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:
f1:02:d9:85:de:39:ab:19:45:5c:b7:f2:92:0e:6d:4e root@lyucan.com
The key's randomart image is:
+--[ RSA 2048]----+
|         o... .  |
|       o..o  . . |
|      o.oo .. .  |
|       ..o=. +   |
|        S.ooE .  |
|        ...* .   |
|         +  o    |
|        o        |
|                 |
+-----------------+

这样就不需要一步步敲了,这里-P指的是私钥的密码,不同于登录密码,这里空着。

然后将~/.ssh/id_rsa.pub复制到目标服务器上去

[root@noblank ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@103.214.143.94
root@103.214.143.94's password: #输入目标服务器密码
Now try logging into the machine, with "ssh 'root@103.214.143.94'", and check in:

.ssh/authorized_keys

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

然后再登录就不需要输入密码了


转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 289211569@qq.com