I created a new user on ubuntu 10 username: codeuser

There is an existing user called "admin". Now, my problem is that I cannot directly connect to the server using the codeuser credentials. But, I can SSH in through "admin" and then su (change the user to codeuser) and it works. How do I get the shell access to the codeuser user ?

This is the output of my files:

cat /etc/passwd


cat /etc/group


iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination          
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:mysql  

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination          

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
  • 2
    Check /etc/ssh/sshd_config for allowed users list. If it is OK, the problem is more complex. Try to connect as "ssh codeuser@your-server -v"
    – HUB
    Apr 1, 2011 at 17:08
  • When you ssh in as codeuser what error message is displayed after entering the codeuser credentials ?
    – user9517
    Apr 1, 2011 at 17:09
  • @HUB it worked [can you please make it an answer, so I can accept it ?]. Strange, I thought I checked that file. Now, do I have to add a user to that file everytime I create a new user ? Isn't there a automatic script / command ?
    – Stewie
    Apr 1, 2011 at 17:13

8 Answers 8


Check /etc/ssh/sshd_config for allowed users list. If it is OK, the problem is more complex. Try to connect as "ssh codeuser@your-server -v"

  • 2
    My sshd_config file does not have any users defined, but I can SSH in as root, and user1, but not user2
    – wruckie
    May 21, 2018 at 16:34
  • 1
    @wruckie In my case, the shell assigned to the user was not correct. If it is suspected, please try editing /etc/passwd. My problem had been solved by changing /usr/bin/bash to /bin/bash. (cf. New Users Can't Login via SSH)
    – ynn
    Nov 28, 2019 at 10:48

On Ubuntu 18.04 I had simply neglected to add my client's public key to the authorized keys file (this post got me thinking about the authorized_keys file: https://superuser.com/a/1337741/413936).

chmod 700 ~/.ssh
cd ~/.ssh
touch authorized_keys
chmod 600 authorized_keys

Then add your client's public key to authorized_keys file.

For whatever reason though, I didn't need to add PasswordAuthentication yes to /etc/ssh/sshd_config on Ubuntu 18.04.3 LTS as other people have mentioned. To be clear, mine is commented out like this # PubkeyAuthentication yes and I restarted both ssh and sshd services and was still able to ssh in.

  • That commented out # PubkeyAuthentication yes really puzzles me - it's either not mentioned on many Debian 10 security guides, or they recommend uncommenting it, yet it seems leaving it commented out still enables login with an SSH key? Mar 14, 2021 at 17:04
  • 1
    @DaveEveritt The comments in the file show what the default values are. Nov 22 at 19:21

Stumble to this thread after create a new user and cannot SSH to the new user. I managed to fix it after looked for the group and user of .ssh folder and authorized_keys file. They were set to root:root, because I copied them from other user's folder with sudo.

So I fix it with:

sudo chown new_user:new_user /home/new_user/.ssh/
sudo chown new_user:new_user /home/new_user/.ssh/authorized_keys

Hope this helps

  • This fixed my problem. Thanks. Oct 27, 2021 at 5:13

Check /var/log/auth.log for any errors. Did you assign codeuser a password using the passwd command?


A quite old post but still valid. Worth checking logs as Marco Ramos mentioned above. In my case with Debian 9 a group must granted with permissions /var/log/auth.log

Nov 23 23:10:46 AreNAS sshd[6765]: User are from not allowed because none of user's groups are listed in AllowGroups

Make sure the public key is correct in this place:


Try to check /var/log/auth.log for possible error messages.

Also, ask the user to try to login with ssh -v, for more verbose output.

Hope this helps!


On new Debian installations (may be even other distributions) you have to enable password login. It started to happen recently. AllowUsers won't help you, PermitRootLogin yes won't help you.

Default configuration in /etc/ssh/sshd_config is:

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

but it won't let you ssh to it with plain text password. You have to uncomment it, restart sshd, insert your ssh key and comment it back or leave it enabled.

You must log in to answer this question.

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