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]# 

你可能感兴趣的:(Linux/unix)