A 系统: 172.16.198.128
B 系统: 172.16.198.130
使用基于主机的非对称密钥方式从B直接登录A.
一、修改A系统上的/etc/ssh/sshd_config,将
RhostsRSAAuthentication
HostbasedAuthentication
PubkeyAuthentication
都设置为 yes
保存退出,重启ssh服务 /etc/init.d/sshd restart
二、以下均在B系统上操作
#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:
93:08:88:88:dc:8f:46:d8:a3:09:fc:35:25:50:d0:fe
#scp -P 16888 ~/.ssh/id_rsa.pub
password:
输入正确密码,回车
id_rsa.pub 100% 396 0.4KB/s 00:00
~/.ssh/id_rsa.pub 公钥已经安全传输到172.16.198.128这台机器上的/root/.ssh/目录下并命名为authorized_keys(必须重命
名为此文件名)
#ssh -p 16888
Enter passphrase for key '/root/.ssh/id_rsa': <------ 如果你在生成密钥时设置了密语,此处输入密语.如果没有输入密语,直接登
入系统
密语正确出现类似如下的登录信息:
Last login: Sat Jul 26 11:16:57 2008 from 172.16.198.130
[root@RHEL5 ~]#
登录172.16.198.128成功,OK!
阅读(10524) | 评论(0) | 转发(0) |