I had a root access to my server and I was logged in through ssh. I I did this in my

AllowUsers john


in this file.

Now after this I rebooted the server. now I am unable to login through root user and unable to login through john as well. nothing is working. Please help?

my root user was this e.g root@ip

If I try to login ssh root@ip through root it says this

Permission denied, please try again.

If I try to login with john it says

Shell access is not enabled on your account! If you need shell access please contact support.

I don't understand why I am unable to login through my root account.

Note: I can successfully login through in WHM

  • 1
    can you post the exact command and (error) output of the terminal when you are trying to log in as john? Apr 10, 2018 at 19:23
  • @ Sebastian Stark if I try to login through john it says Shell access is not enabled on your account! If you need shell access please contact support. Apr 10, 2018 at 19:26
  • @SebastianStark I have updated my question Apr 10, 2018 at 19:28

2 Answers 2


Also note: the AllowUsers specifies that login is allowed only for those user names that match a pattern listed with this keyword. By default, login is allowed for all user names. So, with your configuration, john is the only user that can log in using ssh.

The answer from Sebastian Stark is also correct: root would not be able to login by default, even if you had included root in AllowUsers.

So: I recommend, first, making sure that user john can login correctly. Make sure that john has a shell assigned in /etc/passwd and give him one using chsh if necessary. Then, login as john and use sudo if you need root access.

  • In my case, the user was pointed to a wrong bash "/bin/sh" instead of "/bin/bash" and I can't log in correctly and the error was "Permission denied, please try again.". Fixing to the correct bash restored my login again because I tried the other answers without success so thank you @Martin-v
    – hermeslm
    Jul 3, 2019 at 20:23

By default, logging in as root using password is disabled. You should change the PermitRootLogin setting in /etc/ssh/sshd_config accordingly to allow that, if it is what you want. Alternatively set up public key authentication for the root account. See e. g. How to set up passwordless SSH access for root user for an example. Unfortunately this will be impossible to do without help from your hoster if you really locked yourself out and logging in as john also does not work.

In addition to this, if you do not add root to the AllowUser directive as well, the setting of PermitRootLogin will have no effect anyway.

So to fix your particular problem make those two settings in sshd_config look like this:

PermitRootLogin yes
AllowUsers root john

and then restart sshd or reboot the server. Afterwards you should be able to log in as root using a password.

As for the error message when you are trying to log in as john: This does not look like a normal ssh or Ubuntu error message but rather something your hoster added. You should probably do what it says and contact support.

Safety measures

In general, if you are messing with sshd settings there is an easy way to test things: Simply restart the sshd service using service ssh restart and try things out from another terminal. Do not terminate your existing session. If something goes wrong you still have the running session and can revert the wrong settings.

Rebooting the whole server is never necessary for activating changes to sshd.

  • I have the access of whm. Can I edit the ssd file from there Apr 10, 2018 at 20:11
  • Answer updated, you should be able to recover using those instructions. Apr 10, 2018 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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