使用Linux主机生成的密匙
1、生成密匙
[root@www.linuxidc.com .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:0croot@www.linuxidc.com
2、将 /root/.ssh/id_rsa.pub改名为/root/.ssh/authorized_keys
[root@www.linuxidc.com .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 你的文件