Question

set root password in sshd_config file

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.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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:

  1. sudo passwd root

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