/3'-+bp^=
6yv*AmFh
i/-Xpj]Zf
1)先添加一个维护账号:msa Vyu 0OiGcR
_Bb/~^
2)然后su - msa EG@*J*|S
)/Ee#)z*
3)ssh-keygen -t rsa ZK{VQ~
指定密钥路径和输入口令之后,即在/home/msa/.ssh/中生成公钥和私钥:id_rsa id_rsa.pub l?pZdAE
~y$B#.l
4)cat id_rsa.pub >> authorized_keys V78QV3
至于为什么要生成这个文件,因为sshd_config里面写的就是这个。 '7u#uL,pa1
然后chmod 400 authorized_keys,稍微保护一下。 =HQH;c"
ZV,n-M =
5)用psftp把把id_rsa拉回本地,然后把服务器上的id_rsa和id_rsa.pub干掉 hg]\~#&-
) e;)9~
6)配置/etc/ssh/sshd_config V[HHP_
Protocol 2 TStu)6%`
ServerKeyBits 1024 6wqq"6w
PermitRootLogin no #禁止root登录而已,与本文无关,加上安全些 M})2y+
m!$"-nh9
#以下三行没什么要改的,把默认的#注释去掉就行了 %K\_gR}V
RSAAuthentication yes iRPt0?$
PubkeyAuthentication yes '2WYbcU
AuthorizedKeysFile .ssh/authorized_keys u f.Zg;Vc
]O,!B''8k
PasswordAuthentication no )^|zuYzN
PermitEmptyPasswords no 2(\~z@g
:cnH@:
7)重启sshd L@_IGH
/sbin/service sshd restart TlYeYN5V
%+:%%r=Q
8)转换证书格式,迁就一下putty S=U*is
运行puttygen,转换id_rsa为putty的ppk证书文件 _Su?
VxU
B+ud-M0
9)配置putty登录 &DYHkG
在connection--SSH--Auth中,点击Browse,选择刚刚转换好的证书。 5%rD7/7N
然后在connection-Data填写一下auto login username,例如我的是msa .8<bz4
在session中填写服务器的IP地址,高兴的话可以save一下 q=M!YWz
+?),BRCce
10)解决一点小麻烦 7{
(t_N>
做到这一步的时候,很可能会空欢喜一场,此时就兴冲冲的登录,没准登不进去: 4yV}4f$q
No supported authentication methods available OxqK}%=Bw
YLVIn_\}
这时可以修改一下sshd_config,把 6D_3Hwrs
PasswordAuthentication no临时改为: P3jDx{F
PasswordAuthentication yes 并重启sshd `f,SY
(]n^_G#-$
这样可以登录成功,退出登录后,再重新把PasswordAuthentication的值改为no,重启sshd。 \Bg;}\8X
以后登录就会正常的询问你密钥文件的密码了,答对了就能高高兴兴的登进去。 )mT{w9u
y#!8S{
至于psftp命令,加上个-i参数,指定证书文件路径就行了。