ssh免密登录失败所有解决方法

免密登录

# 免密登录密钥生成
ssh-keygen -b 1024 -t rsa -P ''

# 拷贝密钥到远程主机
ssh-copy-id 10.10.10.11

权限问题

dr-xr-x---. 4 root root 173 8月  21 10:32 /root/             # chmod 550 /root
drwx------  2 root root   29 8月  21 10:31 .ssh              # chmod 700 .ssh
-rw------- 1 root root 648 8月  21 10:53 authorized_keys     # chmod 600 authorized_keys

配置文件问题

PermitRootLogin yes    # 远程root密码登录开启
StrictModes no
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys

安全上下文security context

ls -dZ .ssh
drwx------. root root unconfined_u:object_r:ssh_home_t:s0 .ssh
restorecon -r -vv ~/.ssh    # 修改安全上下文

注:欢迎评论更多的解决方法 _

你可能感兴趣的:(ssh免密登录失败所有解决方法)