ssh免密码登录

环境:三台主机
ceph-ncnode01 192.168.94.61
ceph-ncnode02 192.168.94.77
ceph-ncnode03 192.168.95.60

目标:三台主机两两免密码互连

systemctl stop firewalld
setenforce 0

1、在三台主机上分别添加如下:

#vi /etc/hosts
192.168.94.61 ceph-ncnode01
192.168.94.77 ceph-ncnode02
192.168.95.60 ceph-ncnode03

vi /etc/ssh/sshd_config
PermitRootLogin yes         能让root远程
PasswordAuthentication yes 启用密码认证

2、配置免密码登录

在ceph-ncnode01、ceph-ncnode02、ceph-ncnode03机器上生成秘钥

[root@ceph-ncnode01 ~]# ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
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:
9f:07:12:21:89:17:aa:83:46:50:dd:f1:e4:f1:2f:95 root@jumpserver
The key's randomart image is:
+--[ RSA 2048]----+
|.... o+++        |
|.   o.+= +   .   |
| .  ..  + . E    |
|.. .     . o     |
|..o     S o .    |
|.  .     o +     |
|          o .    |
|           .     |
|                 |
+-----------------+

2.1在ceph-ncnode01节点配置免密码登录

[root@ceph-ncnode01 ~]# cd .ssh/
[root@ceph-ncnode01 ~]# ls
authorized_keys  id_rsa  id_rsa.pub  known_hosts
[root@ceph-ncnode01 ~]# cat id_rsa.pub >> authorized_keys
[root@ceph-ncnode01 ~]# chmod 600 authorized_keys

2.2复制ceph-ncnode01节点的/root/.ssh/文件夹下的所有文件到ceph-ncnode02、ceph-ncnode03节点;

[root@ceph-ncnode01 ~]# scp /root/.ssh/* root@ceph-ncnode02:/root/.ssh/
[root@ceph-ncnode01 ~]# scp /root/.ssh/* root@ceph-ncnode03:/root/.ssh/

2.3验证无密码登录

root@ceph-ncnode01:~# ssh ceph-ncnode02
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-47-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

0 packages can be updated.
0 updates are security updates.


Last login: Tue Sep 19 02:45:53 2017 from 192.168.95.60
root@ceph-ncnode02:~# 

root@ceph-ncnode01:~# ssh ceph-ncnode03
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-47-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

0 packages can be updated.
0 updates are security updates.


Last login: Tue Sep 19 02:45:53 2017 from 192.168.95.60
root@ceph-ncnode03:~# 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值