root access problem after changing ssh_config to PermitRootLogin no

June 13, 2016 366 views
Apache LAMP Stack

Hi people

I hope someone can help me

I created a sudo user
after that i made keys for that user
all workes fine with that user
then i set in ssh_config to PermitRootLogin no
and i think i did that when i loged in a root....
i have the feeling i locked myself out from the server

now the problem is i cant login as root anymore....but i need that to change some stuff around.

Be careful im a Newbie to all this :-)

Anyway I hope some points me in a right direction


2 Answers

Log in as your new user?

  • well that i tried but that user has not enough perms, no clue why but i can not change the sshd_config with that.

    solution for newbie.... DO console... root works still there

    did not know that, had to reset my pwd, because mine is extrem long lol but im back in now.

    thank you for your kind help

    • You could've used sudo after logging in as your new user, but if that didn't work then yes the console is there afterwards.

      Good luck.

A few tips when creating a new user on a fresh droplet. Do these commands when logged in as root:
useradd -m -G sudo newuser (the group sudo depends on your distribution)
passwd root
passwd newuser
chsh -s /bin/bash (changes the log in console)*
mkdir /home/newuser/.ssh && cp /root/.ssh/authorized_keys /home/newuser/.ssh/ (this is if you used the ssh key to create the droplet)*

Now just remove login as root, relog and the new user and you should be fine :)

Have another answer? Share your knowledge.