set root password in sshd_config file

July 27, 2017 2.2k views
Linux Basics Ubuntu 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.

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.

by Etel Sverdlov
SSH keys provide a more secure way of logging into a virtual private server with SSH than using a password alone. With SSH keys, users can log into a server without a password. This tutorial explains how to generate, use, and upload an SSH Key Pair.
Have another answer? Share your knowledge.