Enable Root Login via SSH in Ubuntu 20.04

Техника

SSH root login is disabled by default in Ubuntu 18.04.  SSH server for Ubuntu provides by the openssh-server package and root login is controlled by the PermitRootLogin directive in the OpenSSH server configuration (sshd_config file):

grep -i «rootlogin» /etc/ssh/sshd_config

Root login is disabled, if the PermitRootLogin directive is commented out (# in front) or its value is not set to yes.

Next: Change Ubuntu SSH Port

To let this tutorial work better, please consider the below Prerequisites:

Set Root password

sudo passwd root

you succeed to change the root password, now you need to change some configuration on for the permit root login.

Configure SSH config to permit root login

As you see, the is set to No. It means that the root login via SSH has been disabled. So, to enable root login change the to . Find PermitRootLogin and delete No or without-password and type .

After edit the SSH config file, press and button twice for save and exit.

Restart SSH service for loading new configuration on SSH_config file.

sudo systemctl restart sshd

sudo service sshd restart

Loggin as root

Since the PermitRootLogin parameter controls the ssh root permission, you must change its values. The parameter is /etc/ssh/sshd_config and the value of the PermitRootLogin is ”without-password”. So, you need to ser PermitRootLogin to yes to Permit root login.

How to Enable root login over SSH

Open the ssh configuration file and use your favorite text editor.

Then, Search for PermitRootLogin and change its value to “Yes”. If the line exists and is commented out with a ”#”, remove the ”#”.

Дополнительно:  Получение root прав на samsung galaxy tab s

Now, you can save the updated /etc/ssh/sshd_config file and restart the SSH server. Use the command below to do this:

In this article you will learn How to Allow SSH Root Login on Ubuntu 20.04 LTS Linux step by step.

But root SSH login can be enabled by editing OpenSSH daemon (sshd) configuration.

WARNING! Using SSH root login is a bad idea!

Step 1

$ vim /etc/ssh/sshd_config

Step 2

Find commented PermitRootLogin parameter or manually add

As shown on image:

Step 3

After finish editing configuration file save and close it.

For the changes to take effect, you must restart sshd daemon.

$ sudo systemctl restart ssh

Step 4

Now we need set password for the root with using passwd command:

$ sudo passwd root

$ sudo passwd root
New password:
Retype new password:
passwd: password updated successfully

Now you will be able SSH login as root to your Ubuntu server

Conclusion

Enable SSH Root Login on Ubuntu

To enable Root Login on Ubuntu edit sshd daemon configuration PermitRootLogin parameter to:

1. PermitRootLogin yes2. Save changes3. Restart sshd daemon4. Set password for the root with using passwd command

Discuss article in ArsTech Forum

Read also: How To Setup SSH: Public Key Authentication On Linux

If you like what you are reading, please

Buy me a coffee

Best Steps to Install Perl on Rocky Linux 8

Prerequisites

a) You should have a running Ubuntu 20.04 LTS System.

b) You should have sudo or root access to run privileged commands.

c) You should have OpenSSH Server installed in your System.

For that you need to open /etc/ssh/sshd_config file using our favorite nano editor and then set the parameter value to yes. Then Press Ctrl+X and give Y to save and close the file.

Restart SSH service

After setting the parameter, you need to restart ssh service by using systemctl restart ssh command as shown below.

Дополнительно:  Square root of 23.5

Then check the service status by using systemctl status ssh command. It should show as active and running as you can see below.

Login with root

Reset root password(Optional)

In my project, I have to install some package remotely. If I have to login in debian, I say:

it logs in successfully.

I have login in ubuntu in directly using

it is throw error message in

Permission denied, please try again.

How to solve this problem?

33 gold badges235 silver badges226 bronze badges

asked Aug 23, 2013 at 5:47

6 gold badges43 silver badges55 bronze badges

check the /etc/ssh/sshd_config whether the configure PermitRootLogin yes below # Authentication:. If not yes, it doesn’t permit login as root.

you can change it to yes.

Then, restart ssh service to apply the changes:
sudo service sshd restart

26 silver badges37 bronze badges

answered Aug 23, 2013 at 6:10

Ubuntu documentation says:

By default, the Root account password is locked in Ubuntu.

It also says:

It talks at length about why it’s been done this way.

Enabling the root account:

To enable the Root account (i.e. set a password) use:

Use at your own risk!

Logging in to X as root may cause very serious trouble. If you believe
you need a root account to perform a certain action, please consult
the official support channels first, to make sure there is not a
better alternative.

Do not enable the root account. Do not set a password for the root account.

A better way is to allow root login using public key authentication, not with password. The reasoning is explained in the Debian mailing list archives.

With this setup you should be able to login as root using your private key.

If you have previously enabled the root account, make sure to disable it now:

sudo passwd -l root

Дополнительно:  Root пропадает это как

answered Aug 30, 2013 at 12:12

29 gold badges224 silver badges235 bronze badges

and then do what you want using sudo or get a root shell the recommended way:

and then do your housekeeping. Instead of ‘sudo su’ you also could use ‘sudo -i’, which is equivalent, or ‘sudo -s’, that keeps the current environment.

See Ubuntu Sudo/Root documentation

answered Sep 1, 2013 at 19:42

1 gold badge8 silver badges3 bronze badges

edit your /etc/sshd_config doing:

search for line having PermitRootLogin into Authentication Section and uncomment PermitRootLogin or set PermitRootLogin yes. Or simply add this line to the end of file:

Next you’ll gonna restart ssh daemon doing

service ssh restart

to continue session under your root account

answered Aug 26, 2013 at 18:26

1 silver badge2 bronze badges

So long as:

All that is different was the word sudo was added before carrying out the command

If there are security issues with keys etc then you could take a look at a language called expect — using an expect script you will be able to ssh / telnet what ever it is to a remote host and send passwords etc accordingly

answered Aug 26, 2013 at 18:41

2 gold badges28 silver badges48 bronze badges

answered Aug 30, 2013 at 3:46

8 silver badges19 bronze badges

answered Oct 28, 2014 at 8:17

1 bronze badge

By default, the Root account password is locked in Debian based systems like Ubuntu:

Now set the password for root account:

Simply adding a password for root is not enough.

Incoming ssh connections need to be enabled as below:

Then restart SSH:

sudo service ssh restart;

Finally Restart the system:

answered Feb 8, 2016 at 12:28

3 gold badges31 silver badges31 bronze badges

SSH your machine using root with your keypair

answered May 19, 2018 at 11:57

19 silver badges14 bronze badges

Оцените статью
Master Hi-technology
Добавить комментарий