set root password in sshd_config file

Posted July 27, 2017 14.1k views
Linux BasicsUbuntu 16.04

Hi, i need to enable root ask for password when connecting through ssh, but when i add the line: passwd root in sshd_config file and restart the service it fails. The error message points to that line. I’ve also set PasswordAuthentication to yes, just above passwd root.

Thanks for any help.

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
1 answer

While you are highly encouraged to use SSH keys for authentication when connecting to a server, you can enable access via password for the root account.

You are seeing that error as that line is incorrect. That is a command to run, not a line to put in the file.

First, to permit root logins with a password, you would need to add the following to your sshd_config file:

PermitRootLogin yes
PasswordAuthentication yes

Then to actually set the password for the root account, you will need to run this command:

  • sudo passwd root

It will prompt you to enter a new password for the root user.