在CentOS 上給新同事添加了賬號,但ssh總是提示“Permission denied, please try again.” 現在看一看怎麼解決。
1、首先我的賬號可以登錄,上去看看新賬號的用戶名和密碼是否OK。
檢查一切正常,更換密碼仍然不能登錄。
2、檢查SSHD配置,因爲我的賬號使用key免密登錄,新賬號現在是用戶密碼登錄,待會他在上載密鑰。
查看 /etc/ssh/sshd_config文件,查找這一句, 如果是no的話改成yes
PasswordAuthentication yes
重啓sshd
systemctl restart sshd
3、檢查賬號有沒有被lock,使用解鎖
passwd -u <username>
4、上面都做了,仍然不能登錄,最後看一下SElinux,敲sestatus,SElinux狀態是enforcing, 修改/etc/selinux/config文件,改成disabled 或permissive
SELINUX=permissive
不想重啓的話先設一下:
[root@axing]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 31
[root@axing]# setenforce 0
[root@axing]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: permissive
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 31
再試下用新賬號登錄,一切正常了。