Permission denied please try again ssh error
Solution 1
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.
Solution 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.
Related videos on Youtube
mynameisbutt
Updated on September 18, 2022Comments
-
mynameisbutt almost 2 years
I had a root access to my server and I was logged in through ssh. I I did this in my
AllowUsers john
/etc/ssh/sshd_config
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 thisPermission 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
-
Sebastian Stark about 6 yearscan you post the exact command and (error) output of the terminal when you are trying to log in as john?
-
mynameisbutt about 6 years@ 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.
-
mynameisbutt about 6 years@SebastianStark I have updated my question
-
-
mynameisbutt about 6 yearsI have the access of whm. Can I edit the ssd file from there
-
Sebastian Stark about 6 yearsAnswer updated, you should be able to recover using those instructions.
-
hermeslm almost 5 yearsIn 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