Chinaunix首页 | 论坛 | 博客
  • 博客访问: 305153
  • 博文数量: 85
  • 博客积分: 1508
  • 博客等级: 上尉
  • 技术积分: 791
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-06 11:49
文章分类

全部博文(85)

文章存档

2013年(22)

2012年(63)

我的朋友

分类: LINUX

2012-11-02 17:33:45

1. 在机器A上执行:ssh-keygen -t rsa, 生成id_rsa.pub文件(~/.ssh/id_rsa.pub)

[root@pp102 ~]# ssh-keygen
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:
92:59:44:0f:bf:07:2a:b2:e2:c3:8c:00:ec:02:d3:38 root@pp102


2. 在/~/.ssh/目录下新建authorized_keys文件,并追加id_rsa.pub内容到authorized_keys。
3. 将id_rsa文件拷贝到另一台机器(windows、linux都可以),linux下权限为要为600
4. 如果使用工具登陆则选择使用Key验证方式,并选择制定Key,如果使用ssh或scp命令:
   ssh -i "key_path"   user@ip
   ssh -i "key_path"   user@ip:src_path    dest_path
   ssh -i "key_path"   src_path    user@ip:dest_path

总结:要实现访问Key验证,需要保证:
1、将你的公钥追加到家目录下(~/)的.ssh/目录下的authorized_keys文件
2、在windows下,保证对方拥有你的私钥:id_rsa
   在linux下,不仅要保证对方拥有你的私钥:id_rsa,同时要保证id_rsa的权限为600
阅读(1241) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~