Chinaunix首页 | 论坛 | 博客
  • 博客访问: 88082
  • 博文数量: 38
  • 博客积分: 273
  • 博客等级: 二等列兵
  • 技术积分: 215
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-14 22:01
文章分类

全部博文(38)

文章存档

2012年(14)

2011年(24)

分类:

2012-03-13 15:18:50

使用Linux主机生成的密匙
1、生成密匙
[root@gliethttp .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:
e4:9a:47:a7:b4:8a:0b:98:07:b8:70:de:6b:16:2c:0c


2、将 /root/.ssh/id_rsa.pub改名为/root/.ssh/authorized_keys
[root@gliethttp .ssh]#mv /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys


3、将私钥id_rsa拷贝到远程客户端
1)、如果远程客户端是linux,拷贝到远程客户端/root/.ssh/即可
2)、putty作为远程客户端在


putty不能识别直接从服务器拷贝来的私钥,需要使用puttygen.exe进行格式转换
(1)、打开puttygen.exe --> Conversions --> Import Key
(2)、选择拷贝过来的私钥文件id_rsa
(3)、Save private key->id_rsa.ppk(保存私钥)


4、打开putty.exe
1)、Session --> Host Name (填写服务器地址或者域名)
2)、Connection --> SSH --> Auth (点Browse选择刚生成的id_rsa.ppk)
3)、open
成功打开后出现如下提示:
login as: root
Authenticating with public key "imported-openssh-key"


----------------------------------------------------------------------------------

当然你有可能会遇到这个错误 [因为我遇到了,呵呵]:

Permissions 0755 for '你配置的公钥文件路径' are too open.

这个是因为这几个文件权限设置的有点问题

执行命令: chmod 600 你的文件


然后就可以了……其实网上还是搜得到的……

[我一直很奇怪,我一开始的配置的文件访问权限是很大的,为什么还是会报这个错呢?将权限改小了反而正常了,什么世道来的?高手请指教一下??]

==========================================================================

bash-3.1# ls -al
total 16
drwx------ 2 root root 4096 2010-04-16 22:16 .
drwx--x--- 38 root root 4096 2010-04-16 22:02 ..
-rw------- 1 root root 736 2010-04-16 22:16 id_dsa
-rw-r--r-- 1 root root 224 2010-04-16 22:02 known_hosts


bash-3.1# ssh root@122.115.35.244
Enter passphrase for key '/root/.ssh/id_dsa':
Permission denied (publickey).
bash-3.1# ssh root@122.115.35.244
Enter passphrase for key '/root/.ssh/id_dsa':
Last login: Fri Apr 16 18:08:26 2010 from 123.120.30.117


[root@mail ~]# ifconfig
eth0      Link encap:Ethernet HWaddr 00:02:B3:52:5D:C6
inet addr:122.115.35.244 Bcast:122.115.35.255 Mask:255.255.255.0
inet6 addr: fe80::202:b3ff:fe52:5dc6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:458595 errors:0 dropped:0 overruns:0 frame:0
TX packets:356089 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:332785571 (317.3 MiB) TX bytes:107238105 (102.2 MiB)
Base address:0x2460 Memory:fc320000-fc340000

lo        Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:210535 errors:0 dropped:0 overruns:0 frame:0
TX packets:210535 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:852838527 (813.3 MiB) TX bytes:852838527 (813.3 MiB)

[root@mail ~]#

阅读(951) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~