本文主要是介绍A机与B机的SSH信任关系(直通),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
我有A机和B机两个服务器
A为Client: root@nova
B为Server: 192.168.1.16
目的:我在A机登录到B机的时候输入以下命令ssh 192.168.1.16就可以直接登录,怎么实现呢?
[root@nova .ssh]# 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:
2d:e7:49:c7:d0:bc:0e:ae:e5:d9:5e:cc:21:d8:06:5c rootroot@nova
[root@nova .ssh]# ls -ltr
total 44
-rw-r–r– 1 root root 30106 Aug 7 15:45 known_hosts
drwxr-xr-x 2 root root 4096 Sep 2 16:09 tmp
-rw-r–r– 1 root root 236 Sep 2 16:09 id_rsa.pub
-rw——- 1 root root 887 Sep 2 16:09 id_rsa
[root@nova .ssh]#
[root@nova .ssh]# cat id_rsa.pub >authorized_keys
[root@nova .ssh]#
[root@nova .ssh]# scp authorized_keys root@192.168.1.16:/root/.ssh/
root@192.168.1.16’s password:
authorized_keys 100% 236 0.2KB/s 00:00
[root@nova .ssh]# scp authorized_keys root@192.168.1.16:/root/.ssh/
[root@nova .ssh]# ssh 192.168.1.16
Last login: Wed Sep 2 16:03:51 2009 from 192.168.1.10
[root@192.168.1.16 ~]#
OK …..do any ~
这篇关于A机与B机的SSH信任关系(直通)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!