当前位置:百问十五>百科问答>ssh免密等登录

ssh免密等登录

2024-06-07 21:39:00 编辑:join 浏览量:629

ssh免密等登录

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

ssh-keygen -t rsa

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

ssh-copy-id ~/.ssh/id_rsa.pub root@192.168.1.102

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

/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

root@192.168.1.102's password:

Now try logging into the machine, with: "ssh 'root@192.168.1.102'"

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

[root@shell1-com ~]# ssh root@192.168.1.102

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,免密,登录

版权声明:文章由 百问十五 整理收集,来源于互联网或者用户投稿,如有侵权,请联系我们,我们会立即处理。如转载请保留本文链接:https://www.baiwen15.com/answer/87771.html
热门文章