How to allow password authentication for non-root users? (Root still pubkey only)

Posted June 25, 2020 375 views

I’m wondering if it’s possible to do as mentioned in title.

I want root to still not allow password, but a user is allowed to do so.

The reason is because I need to setup Github Action auto-deployment using and the script is bugged to only allow SSH password.


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hello, @hrsetyono

What you can do is to tweak the ssh config file and allow only PubKey authentication for the root username and have the PasswordAuthentication for the other users enabled.

You can use Match in the sshd_config

PasswordAuthentication no
Match User root
PasswordAuthentication yes
Match all

and then restart the ssh daemon.

Hope that this helps!


So I’m thinking of a hacky solution. After changing the PasswordAuthentication to yes, what if I simply do not set the root password?

That way nobody know the password and my root is still basically secured to PubKey only.

But is there such thing as default root password? If there is, how strong is it?