1:su - xliu
2:
[xliu@qht2 .ssh]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/xliu/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
passphrase too short: have 4 bytes, need > 4 ####四个字符,密码长度达不到要求
Saving the key failed: /home/xliu/.ssh/id_rsa.
[xliu@qht2 .ssh]$ ls
[xliu@qht2 .ssh]$ ls -a
. ..
[xliu@qht2 .ssh]$ ls
[xliu@qht2 .ssh]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/xliu/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/xliu/.ssh/id_rsa.
Your public key has been saved in /home/xliu/.ssh/id_rsa.pub.
The key fingerprint is:
ae:b3:a2:c3:93:3f:0b:94:39:82:44:0a:e5:ff:a6:7c xliu@qht2
[xliu@qht2 .ssh]$
3:cd /home/xliu/.ssh
[xliu@qht2 .ssh]$ cat id_rsa.pub >> authorized_keys
[xliu@qht2 .ssh]$ chmod 400 authorized_keys
4:通过ftp将id_rsa传到windows 桌面
5:vi /etc/ssh/sshd_config
将#ServerKeyBits 768修改为ServerKeyBits 1024
Protocol 2 ##默认就是这个
将#PermitRootLogin yes修改为PermitRootLogin no ##禁止root远程登录
将
#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys
三行的注释去掉即可!
将
#PermitEmptyPasswords no
PasswordAuthentication yes
修改为
PermitEmptyPasswords no
PasswordAuthentication no
6:下载puttygen.exe
点conversions--->import key选中id_rsa(windows桌面上的id_rsa)
如下图:
点save private key我将其命名为xliu.ppk
8:配置putty登录
在connection–SSH–Auth中,点击Browse,选择刚刚转换好的证书。
然后在connection-Data填写一下auto login username,例如我的是xliu
在session中填写服务器的ip(例如:192.168.1.9)地址.
如下:
点ok后,会出现如下的登录界面,输入密码,成功登陆如下:
通过su - 变成root用户如下:
我将/home/xliu/authorized_keys移动到/root目录下!
然后使用root登录,ip地址和证书和上面的一样!
见附件
成功登录后见附件!
阅读(4547) | 评论(0) | 转发(0) |