linux 配置免密码登录

linux 配置免密码登录

 

 

[root@spark3 .ssh]#  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:

81:e2:c7:e7:66:20:a9:25:3b:16:8c:72:b5:b9:11:fa root@spark3

The key's randomart image is:

+--[ RSA 2048]----+

|                 |

|       .         |

|    + . .        |

| o + B   .       |

|o * O + S        |

|.. B = +         |

|  = E   +        |

| . .   o         |

|                 |

+-----------------+

[root@spark3 .ssh]# 

[root@spark3 .ssh]# cat id_rsa.pub    >> authorized_keys

[root@spark3 .ssh]#  ssh-copy-id -i id_rsa.pub root@spark1

The authenticity of host 'spark1 (192.168.157.10)' can't be established.

RSA key fingerprint is c1:57:34:f1:fb:9c:c6:40:c4:6e:68:76:b6:5b:92:90.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'spark1,192.168.157.10' (RSA) to the list of known hosts.

root@spark1's password: 

Now try logging into the machine, with "ssh 'root@spark1'", and check in:

 

  .ssh/authorized_keys

 

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

 

[root@spark3 .ssh]# 

[root@spark3 .ssh]# 

[root@spark3 .ssh]# 

[root@spark3 .ssh]# 

[root@spark3 .ssh]# ssh root@spark1

Last login: Thu Oct 11 17:44:45 2018 from 192.168.157.1

[root@spark1 ~]# 

[root@spark1 ~]# exit 

logout

Connection to spark1 closed.

[root@spark3 .ssh]# 

[root@spark3 .ssh]# 

[root@spark3 .ssh]# 

[root@spark3 .ssh]#  ssh-copy-id -i id_rsa.pub root@spark2

The authenticity of host 'spark2 (192.168.157.11)' can't be established.

RSA key fingerprint is c1:57:34:f1:fb:9c:c6:40:c4:6e:68:76:b6:5b:92:90.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'spark2,192.168.157.11' (RSA) to the list of known hosts.

root@spark2's password: 

Now try logging into the machine, with "ssh 'root@spark2'", and check in:

 

  .ssh/authorized_keys

 

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

 

[root@spark3 .ssh]# 

[root@spark3 .ssh]# 

[root@spark3 .ssh]# 

[root@spark3 .ssh]# ssh root@spark2

Last login: Thu Oct 11 17:44:17 2018 from spark1

[root@spark2 ~]# exit 

logout

Connection to spark2 closed.

 

[root@spark3 .ssh]# 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值