Enable SSH root login on Debian Linux Server

After fresh system installation the root login on the Debian Linux is disabled by default. When you attempt to login as root user to your Debian Jessie Linux server the access will be denied eg:

login as: root
root@sisrv.net's password:
Access denied
root@sisrv.net's password:

To enable SSH login for a root user on Debian Linux system you need to first configure SSH server. Open /etc/ssh/sshd_config and change the following line using  sudo nano /etc/ssh/sshd_config

FROM:
#PermitRootLogin prohibit-password
TO:
PermitRootLogin yes

Once you made the above change restart your SSH server:

# sudo /etc/init.d/ssh restart
[ ok ] Restarting ssh (via systemctl): ssh.service.

Now, check whether the SSH service is running with the following command:

$ sudo systemctl status ssh

As you can see below, the SSH service is active or running. Now, you can connect to this computer remotely via SSH.

● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2020-08-25 11:47:05 UTC; 1min 40s ago
     Docs: man:sshd(8)
           man:sshd_config(5)
  Process: 978 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
 Main PID: 979 (sshd)
    Tasks: 1 (limit: 2320)
   Memory: 1.1M
   CGroup: /system.slice/ssh.service
           └─979 /usr/sbin/sshd -D

systemd[1]: Starting OpenBSD Secure Shell server...
sshd[979]: Server listening on 0.0.0.0 port 2220.
sshd[979]: Server listening on :: port 2220.
systemd[1]: Started OpenBSD Secure Shell server.

Default root password on Debian 10

By default, there is no default password for the root account on Debian 10.

This is because the root account is locked by default and setting a root password will unlock the account.

Change User Password using passwd

If you try to change your root password like you normally do, you will get:

debian@server:~$ passwd root
passwd: You may not view or modify password information for root.

try 

debian@server:~$ sudo passwd root

The first way to change the user password is to use the passwd command.

$ passwd

Changing password for devconnected.
Current password:
New password:
Retype new password:
passwd: password updated successfully

If you type the same password, you are going to have a warning message saying

Password unchanged

Change Another User’s Password with passwd

Before running the passwd command, make sure that you have sudo rights on your Debian 10 host.

To check sudo rights quickly, run the sudo command and make sure that you have error messages.

$ sudo -v

If you have sudo rights, you can run the passwd command.

Note: when updating another’s user account, you are not forced to know the current user password. It is very handy if you want to restrict the access to a user.

$ sudo passwd user/root

New password:
Retype new password:
passwd: password updated successfully
  • root login, enable SSH, enable root
  • 54 Users Found This Useful
Was this answer helpful?

Related Articles

SSH login without password

You want to use Linux and OpenSSH to automate your tasks. Therefore you need an automatic login...

How to remove a Linux user

How do I drop or remove old users account from my Linux server? I can login using the user’s SSH...

How to restrict and except SSH access to specific IPs

Once your IP is public it gets attention from so many bots in the internet that do brute force...

How to lock and unlock user account in linux

With the help of two commands you can lock and unlock the user account in Linux. To Lock the...

Adding a user to a group

Synopsis This article describes how to add a Linux user (account) to a group. Environment...

Powered by WHMCompleteSolution