关于SSH 如何建立RSA,这里就不罗列了,网上一搜一箩筐。这里简要的说一下配置不成功可能出现的问题。

先说明一下流程:

1 请求SSH

[root@www.linuxidc.com .ssh]ssh user@192.168.33.24
2 检查root下的.ssh目录中的id_rsa.pub内容

3 到192.168.33.24的/home/user/.ssh中查找授权key,authorized_keys是否包含2里面的id_rsa.pub内容

4 如果包含,SSH请求通过,以user身份登陆192.168.33.24中。

 

可能出现的问题:

 1 配置完authorized_keys要重新启动sshd服务

/etc/init.d/sshd restart  
2 .ssh文件夹具有可访问的权限(针对普通用户而言,.ssh文件夹要具有更高的读取权限,因为要进行第3步)

chmod -R 750 /home/user/.ssh  
3 作为被访问放的sshd服务配置是否正确,开启RSA认证,公钥认证,授权文件路径(尽管默认是读取的)

vi /etc/ssh/sshd_config  
配置结果:

RSAAuthentication yes   
PubkeyAuthentication yes   
AuthorizedKeysFile      .ssh/authorized_keys   

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts    
#RhostsRSAAuthentication no    
# similar for protocol version 2    
#HostbasedAuthentication no    
# Change to yes if you don't trust ~/.ssh/known_hosts for    
# RhostsRSAAuthentication and HostbasedAuthentication    
#IgnoreUserKnownHosts no    
# Don't read the user's ~/.rhosts and ~/.shosts files    
#IgnoreRhosts yes    

# To disable tunneled clear text passwords, change to no here!    
#PasswordAuthentication yes    
#PermitEmptyPasswords no    
PasswordAuthentication yes  
4 有时候,会因为.ssh中的权限过于开放导致互信失效,提示权限过于OPEN,其实是SSH检测到您的id_rsa私钥权限过高所致

[默认用户家目录权限为700,切记!]

chmod u+rw ~/.ssh/id_rsa  
5 在生成RSA之后,一旦更改过user密码会对authorized_keys有影响,只能重新在生成个rsa文件了