2009-06-22 12:02:07| 分类: 《linux服务器》 | 标签: |举报 |字号大中小 订阅
实现SSH无密码登陆,多用来在两台服务器间在无人监控管理执行脚本时无密码传输数据。
这种情况适合于内网的两台机器使用的方便,但是很不安全所以要慎用。
如果想从host1不用密码登陆到host2,那么如下步骤:
首先建立本机的公私密钥
[root@host1 root]# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
9b:40:4c:a1:9c:d0:10:d6:bf:1b:5f:0d:8c:6b:0c:0a
[email=root@host1]root@host1[/email]
[root@host1 root]#
注意以上不要输入passphrase(一直按回车就可以了。)
然后将公钥文件传送到需要登陆的服务器
[root@host2 .ssh]#scp root@host1IP:/root/.ssh/id_dsa.pub ./authorized_keys2
root@host1IP's password:
id_dsa.pub 100% 604 0.6KB/s 00:00
[root@host1.ssh]#ssh host2IP
评论