手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux 远程登录(telnet ssh)

[日期:2013-03-25] 来源:Linux社区  作者:missedyou [字体:大 中 小]

ssh等价性

[root@rhel5-1 .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:
a1:ef:d7:94:03:da:bb:64:f2:7d:4f:73:ad:92:29:a1 root@rhel5-1.xfcy.org
[root@rhel5-1 .ssh]# ls
id_rsa id_rsa.pub "id_rsa文件必须存在"
[root@rhel5-1 .ssh]# cat id_rsa.pub >> key
[root@rhel5-1 .ssh]# scp key rhel5-2:/root/.ssh/
The authenticity of host 'rhel5-2 (192.168.1.22)' can't be established.
RSA key fingerprint is 26:5a:c3:e5:58:f0:0d:57:94:02:b0:7f:01:27:34:2a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rhel5-2,192.168.1.22' (RSA) to the list of known hosts.
root@rhel5-2's password:
key 100% 403 0.4KB/s 00:00

 

[root@rhel5-2 .ssh]# ls
key
[root@rhel5-2 .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:
19:51:ec:c9:87:b3:7e:de:b0:e2:7d:b4:89:09:60:8f root@rhel5-2.xfcy.org
[root@rhel5-2 .ssh]# ls
id_rsa id_rsa.pub key
[root@rhel5-2 .ssh]# cat id_rsa.pub >> authorized_keys
[root@rhel5-2 .ssh]# cat key >> authorized_keys
[root@rhel5-2 .ssh]# scp authorized_keys rhel5-1:/root/.ssh/
The authenticity of host 'rhel5-1 (192.168.1.11)' can't be established.
RSA key fingerprint is 26:5a:c3:e5:58:f0:0d:57:94:02:b0:7f:01:27:34:2a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rhel5-1,192.168.1.11' (RSA) to the list of known hosts.
root@rhel5-1's password:
authorized_keys 100% 806 0.8KB/s 00:00

[root@rhel5-2 .ssh]# ls
authorized_keys id_rsa id_rsa.pub key known_hosts

[root@rhel5-2 .ssh]# ssh rhel5-1
Last login: Thu Aug 30 15:41:33 2012 from rhel5-2.xfcy.org
此时从rhel5-2通过ssh登录到rhel5-1已不需要密码,rhel5-1通过ssh登录到rhel5-2也不需要密码
注:两端的id_rsa文件必须存在

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款