多台Linux服务器之间互相免密登陆

环境:

三台Linux 服务器    

 IP                                          Release                         Hostname                                          

192.168.200.131              centos7                            ceph-node1

192.168.200.130              centos7                            ceph-node2

192.168.200.136              centos7                            ceph-node3


配置ceph-node1无密码连接ceph-node2和ceph-node3:

[root@ceph-node1 ~]# ssh-keygen -t rsa
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:
SHA256:FGrYUe6qiaKaRXz4sp/HLWJJvDeUsGaV+++EKe9fKwc root@ceph-node1


关于 ssh-keygen的参数解释:http://www.cnblogs.com/wangkongming/p/6362397.html


 [root@ceph-node1 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.200.130
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/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.200.130's password:

Number of key(s) added: 1

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

在客户端的/root目录下就是出现 .ssh文件夹,下面是对应的authorized_keys文件。

在ceph-node1上ssh到ceph-node2,这样就能实现无密码访问了。

 [root@ceph-node1 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.200.136

这只是在ceph-node1上配置了对于ceph-node2和ceph-node3的无密码访问,接下来配置ceph-node2和ceph-node3对于其他服务器的无密码访问,只需要在对应的节点上做以上相同的操作即可。


如果要配置ceph-node2和ceph-node3无密码访问其他的服务器,只是在对应的节点重复以上操作即可。










评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值