linux多机器免密登录

环境:

三台Linux 服务器    

 IP                                   Release                         Hostname                                          

192.168.31.135              centos6.5                            HDFS

192.168.31.133              centos6.5                            HDFS-01

192.168.31.134              centos6.5                            HDFS-02

 

配置HDFS 无密连接HDFS-01、HDFS-02

[root@HDFS ~]# ssh-keygen -t rsa
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:
6b:f0:c3:1e:f3:bd:00:3b:50:cf:66:c6:d0:42:66:3d root@HDFS
The key's randomart image is:
+--[ RSA 2048]----+
|        +.       |
|       + .E      |
|        + ..     |
|       . *       |
|      o S B      |
|       = B       |
|        @ .      |
|       o * o     |
|        . . o.   |
+-----------------+

在 .ssh 目录下生成公钥和私钥:

[root@HDFS .ssh]# ll
total 8
-rw-------. 1 root root 1679 Oct  9 15:34 id_rsa
-rw-r--r--. 1 root root  391 Oct  9 15:34 id_rsa.pub

将公钥复制到需要免密连接的服务器上(HDFS-01、HDFS-02)

[root@HDFS .ssh]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.31.133
The authenticity of host '192.168.31.133 (192.168.31.133)' can't be established.
RSA key fingerprint is aa:0a:2f:20:c3:58:c5:00:da:8f:9d:ba:23:25:3e:ac.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.31.133' (RSA) to the list of known hosts.
root@192.168.31.133's password: 
Now try logging into the machine, with "ssh 'root@192.168.31.133'", and check in:

  .ssh/authorized_keys

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

免密登录: ssh 192.168.31.133

[root@HDFS .ssh]# ssh 192.168.31.133
Last login: Tue Oct  9 15:29:22 2018 from hdfs
[root@HFDY-01 ~]# exit

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值