Linux SSH无秘钥登录

SSH 无秘钥登录到其他机器

  • 直接上命令

###############################MASTER###############################
[root@cluster1 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
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:
76:9a:a4:c1:46:0a:94:6b:d5:83:49:db:3c:e8:e4:e7 root@cluster1
The key's randomart image is:
+--[ RSA 2048]----+
|  .o.+           |
| .. +=o          |
|  .o+ =.         |
|  o= + .         |
| .  + = S .      |
|     + = +       |
|      E o        |
|                 |
|                 |
+-----------------+
# 这里不设置权限可能导致后面连接还是要输入密码
[root@master ~]# chmod 700 .ssh
[root@master ~]# chmod 600 .ssh/id_rsa.pub
[root@master ~]# ssh-copy-id 192.168.10.131
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.10.131 (192.168.10.131)' can't be established.
ECDSA key fingerprint is SHA256:8d4j7j22HMiyaUWObSx9VWd/7v854UN5VUXuV1V0hrY.
ECDSA key fingerprint is MD5:14:10:4b:a9:65🇦🇩ff:03:25:ff:c9:9b:84:50:c1:f3.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.10.131's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '192.168.10.131'"
and check to make sure that only the key(s) you wanted were added.

###############################CLUSTER###############################
[root@cluster1 ~]# ll .ssh/
total 4
-rw-------. 1 root root 393 May  9 08:01 authorized_keys

# 测试是否正常
[root@master ~]# ssh 192.168.10.131 date
Wed May 9 08:04:12 PDT 2018


最后修改:2018/05/09 23:08
如果觉得我的文章对你有用,请随意赞赏

发表评论

颜文字