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 11
By default, there is no default password for the root account on Debian 11.
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
or
su
passwd
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