Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm executed this commands with root user i'm on a CentOS 6.3 server:

#useradd newuser
#passwd newuser

#visudo

then I added this line at end of file:

AllowUsers newuser

#service sshd restart
#exit

Now, I can't access server with deployer or root user! Both accounts return:

**Permission denied, please try again.**

Any suggestions?

EDIT: Why add AllowUsers newuser dont allows newuser to login by ssh?

share|improve this question
2  
suggestions to do what? fix the "cannot login" issue or "allow root to log in"? –  chutz Dec 12 '12 at 16:13
1  
check your logs for a better error –  Mike Dec 12 '12 at 16:15
    
@chutz, It's possible to work around this problem and can login again by ssh? –  Rodrigo Dec 12 '12 at 16:27
    
Enable root to login via ssh in /etc/ssh/sshd_config PermitRootLogin:yes and see if you can get in with root. –  cole Dec 12 '12 at 16:33

2 Answers 2

AllowUsers, quoting man sshd_config, "If specified, [allows] only user names that match one of the patterns".

To work around the problem, try logging in as newuser, and then use sudo -i (if newuser is allowed to run the command) or su root (if you know the root password) to become root and take the AllowUsers line out. After modifying sshd_config, restart sshd.

share|improve this answer
    
But I can't access server with newuser user –  Rodrigo Dec 12 '12 at 16:24
    
Can you get on to the server at all? Are you still logged in? –  jim_m_somewhere Dec 12 '12 at 19:36

Make sure port 22 is open:

netstat -tulpn | grep :22

I'm assuming you have not turned off iptables. You can either a.) turn them off

service iptables save
service iptables stop
chkconfig iptables off

Or, add a rule:

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

Then restart ssh, root login via ssh is disable by default (usually) so you would need to edit the ssh config if you want root login:

vi /etc/ssh/sshd_config
PermitRootLogin:yes
share|improve this answer
2  
"Permission denied" is normally not related to connectivity issues. –  chutz Dec 12 '12 at 16:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.