1. # 建立密钥对(这里是在root用户下)
    2. ssh-keygen
    3. # 安装公钥
    4. cd ~/.ssh
    5. cat id_rsa.pub >> authorized_keys
    6. # 确保权限正确
    7. chmod 600 authorized_keys
    8. chmod 700 ~/.ssh
    9. # 配置文件
    10. vi /etc/ssh/sshd_config
    11. RSAAuthentication yes
    12. PubkeyAuthentication yes
    13. PermitRootLogin yes
    14. # 可以关闭密码登录
    15. PasswordAuthentication no
    16. # 重启SSH服务
    17. service sshd restart