I created a new user in my CentOS web server with useradd. Added a password with passwd. But I can't log in with the user via SSH. I keep getting 'access denied'. I checked to make sure that the password was assigned and that the account is active.

/var/log/secure shows the following error:

Aug 13 03:41:40 server1 su: pam_unix(su:auth): authentication failure; logname= uid=500 euid=0 tty=pts/0 ruser=rwade rhost= user=root

Please help, Thanks

Thanks for the responses so far: I should add that it is a VPS on a remote computer, fresh out of the box. I can log in as the root user quite fine. I can also su to the new user, but I cannot log in as the new user.

Here is my sshd_config file:

#       $OpenBSD: sshd_config,v 1.73 2005/12/06 22:38:28 reyk Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options change a
# default value.

#Port 22
#Protocol 2,1
Protocol 2
#AddressFamily any
#ListenAddress ::

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 768

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile     .ssh/authorized_keys

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
GSSAPICleanupCredentials yes

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication mechanism.
# Depending on your PAM configuration, this may bypass the setting of
# PasswordAuthentication, PermitEmptyPasswords, and
# "PermitRootLogin without-password". If you just want the PAM account and
# session checks to run without PAM authentication, then enable this but set
# ChallengeResponseAuthentication=no
#UsePAM no
UsePAM yes

# Accept locale-related environment variables
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10
#PermitTunnel no
#ChrootDirectory none

# no default banner path
#Banner /some/path

# override default of no subsystems
Subsystem       sftp    /usr/libexec/openssh/sftp-server
  • There are many reasons you can get this error. Try logging in using ssh -vv <hostname> and checking the verbose output to see what it tries and where it dies. If you still are stuck provide the output and your sshd config file (/etc/ssh/sshd_config on CentOS) and that will help you get a precise answer. Aug 13, 2010 at 22:31
  • Can you login locally as the user? ie. is it the user account, not the sshd.
    – Alex
    Aug 13, 2010 at 22:33
  • 1
    The log entry you provided was generated by the su command, not sshd. You should be looking for entries that start with "<date> <hostname> sshd: ..."
    – chuckx
    Aug 13, 2010 at 22:59
  • @Ron if your ssh server is configured not to allow users with root permission to login and the user you create has root permission anywhere it won't let your user login. You can check that by running the follow command: cat /etc/ssh/sshd_config |grep PermitRootLogin if nothing is displayed then it means root can login if it displays PermitRootLogin no means root cannot login unless it is logged in from a normal user.
    – Prix
    Aug 13, 2010 at 23:57
  • 3
    @Ron: please post your comment re the resolution as an answer and accept it, for the benefit of those trying to assist others in serverfault and those experiencing a similar issue in future. Thanks. Nov 18, 2010 at 14:23

3 Answers 3


Ron, Check the /etc/security/access.conf file to see if the user, or group, is not being allowed access.

For example:

Disallow console logins to all except admins

-:ALL EXCEPT root admins :LOCAL

Disallow logins to all except to those that need it

-:ALL EXCEPT root ssh_users :ALL

Disallow direct login from anywhere

-: service_account :ALL


Perhaps your user get noshell so the login is successful but could not put you on a shell.

check your /etc/passwd files, eg:

# grep sumodirjo /etc/passwd

check the last part, in example below /bin/bash, if your user get /bin/false or /bin/nologin try to change it to /bin/bash.


I don't see an allowuser directive on your sshd config. This directive tells the ssh daemon what users can and can't SSH directly into the computer.

If you put allowuser <some username> then restart/reload the ssh daemon, you will be able to SSH into the computer using that username.

  • no allowuser line means no restriction (root is handled separately).
    – Sirex
    Jul 9, 2012 at 3:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .