遇到在密码正确的情况下ssh密码不对,最后一种是我遇到的问题上面的是网上大家遇到的总结一下。我的问题是selinux没有关闭,被改动了配置。

1、权限问题

.ssh目录,以及/home/当前用户 需要700权限,参考以下操作调整

sudo chmod 700 ~/.ssh

sudo chmod 700 /home/当前用户

.ssh目录下的authorized_keys文件需要600或644权限,参考以下操作调整

sudo chmod 600 ~/.ssh/authorized_keys

2、StrictModes问题

编辑

sudo vi /etc/ssh/sshd_config

找到

#StrictModes yes

改成

StrictModes no

3    RSAAuthentication问题/etc/ssh/sshd_config

RSAAuthentication yes
PubkeyAuthentication yes



 

如果还不行,可以用ssh -vvv 目标机器ip 查看详情,根据输出内容具体问题具体分析了



4、#getenforce 查看selinux状态

[root@localhost ~]# getenforce ---------------查看selinux状态 

Enforcing   ----------------------------------显示正在实施运行

#setenforce 0|1 ------------------------------设置selinux关闭|开启

[root@localhost ~]# getenforce ---------------再查看selinux状态

Permissive------------------------------------可以关闭,但只是零时关闭

vi /etc/selinux/config

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

#     enforcing - SELinux security policy is enforced.

#     permissive - SELinux prints warnings instead of enforcing.

#     disabled - No SELinux policy is loaded.

SELINUX=disabled    --------------------------需要把原来的enforcing改成disabled

# SELINUXTYPE= can take one of these two values:

#     targeted - Targeted processes are protected,

#     mls - Multi Level Security protection.

SELINUXTYPE=targeted