现在使用linux的人越来越多,一般在windows连到linux都用SecureCRT, 为了安全,我使用密钥认证,看了很多文章,都写的不太明白,经历过痛苦的过程后,我终于成功了。现在把安装的过程写下来,为想使用SecureCRT,/ssh的朋友提供一条方便之门
我的sshd_config的内容为
Port 22
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
KeyRegenerationInterval 1h
SyslogFacility AUTHPRIV
LoginGraceTime 5m
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
IgnoreRhosts yes
PermitEmptyPasswords no
PasswordAuthentication yes
ChallengeResponseAuthentication no
GSSAPIAuthentication yes
GSSAPICleanupCredentials yes
UsePAM yes
X11Forwarding yes
想用哪个用户登陆就su到哪个用户 如su test
ssh-keygen -t dsa
就会在~/.ssh下生成id_dsa和id_dsa.pub,id_dsa是密钥,有这个的人都可以登陆到你生成密钥的机器上,所以要保管好这个文件,把id_dsa这个文件复制到windows的一个目录下,点开SecureCRT选择一个用户如下图
右击选属性,点SSH2->PublicKey->Properties,选择如下图所示,
然后把生成的id_dsa.pub 复制成authorized_keys就可以用密钥登陆linux了。