【Linux】配置SSH免密登录

环境说明

假设我们有三台机器分别为bigdata111,bigdata112,bigdata113,三台机器均为centos 7系统。

配置SSH免密登录

(1)利用Xshell的发送键输入到所有会话功能,在三台机器生成秘钥

[root@bigdata111 hadoop-2.8.4]# ssh-keygen
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:
cc:47:37:5a:93:0f:77:38:53:af:a3:57:47:55:27:59 root@bigdata111
The key's randomart image is:
+--[ RSA 2048]----+
|              .oE|
|             ..++|
|          . B = +|
|       o . + * * |
|        S o   + o|
|         .   . o.|
|            . .  |
|             .   |
|                 |
+-----------------+

(2) 利用Xshell的发送键输入到所有会话功能,将秘钥添加到集群中各个机器的秘钥库中

[root@bigdata111 hadoop-2.8.4]# ssh-copy-id bigdata111
[root@bigdata111 hadoop-2.8.4]# ssh-copy-id bigdata112
[root@bigdata111 hadoop-2.8.4]# ssh-copy-id bigdata113

(3)查看秘钥库是否存在

[root@bigdata111 .ssh]# cd /root/.ssh
[root@bigdata111 .ssh]# ls
authorized_keys  id_rsa  id_rsa.pub  known_hosts
[root@bigdata111 .ssh]# cat authorized_keys 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7cSXZDdNJ0Cg+1wyVoCn4pWEAxy/13/ekg//YVkGwEsR6HO4XaYxxstVBij5JoTEEjSDNmz2HifTZDB098py3x882ZLVHJllJWzXYX4gVof/tmdmk5AJbhIlX3SoauTrrrzFiMtuXKdu6slvzhs9IbDp68xCUNiVI06OnWFSuhQc8Td+tekwlFPfm+v3W/PqUUgQAd+OAqOUC2vEjjnACQNw/wgGvF/lqrXDv5ZIFmYCBlB7YxwP9RykOvAzEe7w2W7TOt0K8V8oKKTui4aZuahWDbsGwlD7TAQRkilXkG59XG48AWOQoU/XFxph+XECqJzjmdxYedzY8inYW/Lfx root@bigdata111
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYyMVfLaL9w9sGz5hQG96ksUN5ih2RHdwsiXBpL/ZRG7LasKS+OQcszmc61TJfV0Vjad7kuL9wlg2YqlVIQJvaIUQCw4+5BrO0vCy4JBrz/FiDjzxKx0Ba+ILziuMxl35RxDCVGph17i2jpYfy6jGLejYK9kpJH4ueIj8mm+4LTKabRZTcjdNNI0kYM+Tr08wEIuQ45adqVU9MpZc/j6i1FIr4R/RabyuO1FhEh0+Oc5Xbm3jSAYH0MgEvK1cuG9wmX7SaB/opO00Ts+nW/P4umeZQUy51IQSRdUF6BlMrshnCSlKHnuLv2eSCx9yv3QuQMWHnL/SOXUgTnIuzbrv9 root@bigdata112
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDoBOAT/n1QCnaVJtRS1Q9GeoP665gIayWxpSWbjEFus4DL4as5S9jAIhBQWrTnvZzm+Skb4dxGPgdPYLaMFX9tdDYPPsnnRR92sLpRw9gwvG5ROL5XPpV2X+Yxl6yACmlMT0JP1uk+Ekm623n6wtBSBP1BDtJ/fhXkRX6bo2kuXs4BvmP76cikdGBDygKNIEMPTcs6p2lfOnuVdQLSCGm+Q9NswKSBVElNyywNl5J9L/5kIzGXnoGtwhQtdrOjZ+c1tyiwhCz42I3c4z0Sb/zH3OFtHCvRG7cF72uDFxe1QwVJ4h1hJ1dmtwVCckNMbmmgK72PsN8Zg4Y8XtBXgX8n root@bigdata113


(4)验证SSH免密码登录是否配置成功

[root@bigdata111 .ssh]# ssh bigdata112
Last login: Mon Aug  5 09:23:11 2019 from bigdata112
[root@bigdata112 ~]# ssh bigdata111
Last login: Mon Aug  5 09:09:23 2019 from 192.168.1.1
posted @ 2019-09-02 23:21  ShadowFiend  阅读(595)  评论(0编辑  收藏  举报