ssh免密等登录

A:主机shell-com             B主机:NBU-master1-com

ssh-keygen -t rsa

需要按下三次回车,这个时候会在~/.ssh文件下生成文件


ssh-copy-id ~/.ssh/id_rsa.pub [email protected]

[root@shell1-com ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]

/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

[email protected]'s password:

Now try logging into the machine, with: "ssh '[email protected]'"

and check to make sure that only the key(s) you wanted were added.

[root@shell1-com ~]# ssh [email protected]

Last failed login: Fri Jun 15 10:15:25 CST 2018 from 192.168.2.31 on ssh:notty

There was 1 failed login attempt since the last successful login.

Last login: Fri Jun 15 10:10:03 2018 from 192.168.2.31

[root@nbu-master1 ~]# exit

logout

Connection to 192.168.1.102 closed.

这样就可以实现A主机登录B主机免密码。

仅供参考

你可能感兴趣的:(ssh免密等登录)