CentoOS SSH访问

我用root用户执行这个命令,我在CentOS 6.3服务器上:

#useradd newuser #passwd newuser #visudo 

然后我在文件的末尾添加了这一行:

 AllowUsers newuser #service sshd restart #exit 

现在,我无法使用部署者或root用户访问服务器! 两个帐户都返回:

 **Permission denied, please try again.** 

有什么build议么?

编辑:为什么添加AllowUsers newuser不允许新用户通过SSHlogin?

AllowUsers ,引用man sshd_config ,“如果指定,只允许匹配其中一个模式的用户名”。

要解决此问题,请尝试以新用户身份login,然后使用sudo -i (如果允许newuser运行该命令)或su root (如果您知道root密码)成为root用户,并将AllowUsers行取出。 修改sshd_config ,重新启动sshd

确保端口22打开:

 netstat -tulpn | grep :22 

我假设你还没有closuresiptables。 你也可以把它关掉

 service iptables save service iptables stop chkconfig iptables off 

或者,添加一条规则:

 vi /etc/sysconfig/iptables -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT service iptables restart 

然后重新启动ssh,通过ssh进行rootlogin是默认禁用的(通常是),所以如果你想rootlogin,你需要编辑ssh config:

 vi /etc/ssh/sshd_config PermitRootLogin:yes