使用Linux主机生成的密匙linux
1、生成密匙vim
[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):ssh
Enter passphrase (empty for no passphrase):sy2013./ide
Enter same passphrase again:sy2013./spa
Your identification has been saved in /root/.ssh/id_rsa.域名
Your public key has been saved in /root/.ssh/id_rsa.pub.it
The key fingerprint is:io
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、ssh服务端配置
vim /etc/ssh/sshd_config
# 是否容许用户自行使用成对的密钥系统进行登入行为,仅针对 version 2。
# 至于自制的公钥数据就放置于用户家目录下的 .ssh/authorized_keys 内
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
#有了证书登陆了,就禁用密码登陆吧,安全要紧
PasswordAuthentication no
#禁用root帐户登陆,非必要,但为了安全性,请配置
PermitRootLogin no
# 是否让 sshd 去检查用户家目录或相关档案的权限数据,
# 这是为了担忧使用者将某些重要档案的权限设错,可能会致使一些问题所致。
# 例如使用者的 ~.ssh/ 权限设错时,某些特殊状况下会不准用户登入
StrictModes no
5、打开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 你的文件