- Remote login as root in ubuntu
- 10 Answers 10
- How to Enable root user for SSH Authentication on Ubuntu 20.04 LTS
- How to Enable root user for SSH Authentication on Ubuntu 20.04 LTS
- Step 1: Prerequisites
- Step 2: Edit /etc/ssh/sshd_config File
- Step 3: Restart SSH service
- Step 4: Login with root
- Step 5: Reset root password(Optional)
- How To Allow SSH Root Login On Ubuntu 20.04
- Allow SSH Root Login on Ubuntu
- Step 1
- Step 2
- Step 3
- Step 4
- Conclusion
- Enable Root Login via SSH in Ubuntu 20.04
- Enable Root Login via SSH in Ubuntu 20.04
- Set Root password
- Configure SSH config to permit root login
- conclusion
Remote login as root in ubuntu
It is a security risk to enable root login via ssh. Because, malicious programs may attempt brute force login on root@some-server. And if they succeed they can do what they want.
You want to login as root. You don’t need to. Login using your personal account and use sudo as needed.
10 Answers 10
check the /etc/ssh/sshd_config whether the configure PermitRootLogin yes below # Authentication: . If not yes , it doesn’t permit login as root.
Then, restart ssh service to apply the changes: sudo service sshd restart
By default, the Root account password is locked in Ubuntu.
Please keep in mind, a substantial number of Ubuntu users are new to Linux. There is a learning curve associated with any OS and many new users try to take shortcuts by enabling the root account, logging in as root, and changing ownership of system files.
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.
- Open /etc/ssh/sshd_config and check if PermitRootLogin is set to yes . If not, then set it to yes and restart ssh with sudo service ssh restart
- Create the .ssh directory in root’s home if it doesn’t exist and make sure it has strict permissions:
sudo -i mkdir -p .ssh sudo -i chmod 700 .ssh
cat id_rsa.pub | sudo -i tee -a .ssh/authorized_keys sudo -i chmod 600 .ssh/authorized_keys
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:
How to Enable root user for SSH Authentication on Ubuntu 20.04 LTS
In this article, I will take you through the steps to enable root user for ssh authentication on Ubuntu 20.04 LTS. If you are Linux user or professional then you might be aware that by default on Ubuntu based systems, root user will not be enabled for ssh authentication due to security purposes. You always need to login with non-root user account and then if you need you can switch to root user after providing correct credentials.
While in most of the cases this works really well but some times you might get a situation when you need to have direct root user access to perform some important task. In those situations, you need to enable root user for SSH authentication. This can be easily done using steps shown in below section. More about SSH Protocol.
How to Enable root user for SSH Authentication on Ubuntu 20.04 LTS
Step 1: 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.
Step 2: Edit /etc/ssh/sshd_config File
By default if you have check PermitRootLogin parameter using grep -i permitrootlogin /etc/ssh/sshd_config command then you will see it is set as prohibit-password . You need to change this parameter to yes to enable root user authentication.
root@localhost:~# grep -i permitrootlogin /etc/ssh/sshd_config PermitRootLogin prohibit-password # the setting of "PermitRootLogin without-password".
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.
root@localhost:~# nano /etc/ssh/sshd_config # $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $ # This is the sshd server system-wide configuration file. See # sshd_config(5) for more information. # This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin # The strategy used for options in the default sshd_config shipped with # OpenSSH is to specify options with their default value where # possible, but leave them commented. Uncommented options override the # default value. Include /etc/ssh/sshd_config.d/*.conf #Port 22 #AddressFamily any #ListenAddress 0.0.0.0 #ListenAddress :: #HostKey /etc/ssh/ssh_host_rsa_key #HostKey /etc/ssh/ssh_host_ecdsa_key #HostKey /etc/ssh/ssh_host_ed25519_key # Ciphers and keying #RekeyLimit default none # Logging #SyslogFacility AUTH #LogLevel INFO # Authentication: #LoginGraceTime 2m PermitRootLogin yes #StrictModes yes #MaxAuthTries 6 #MaxSessions 10
After changing the parameter, you can verify it by again by using the same grep -i permitrootlogin /etc/ssh/sshd_config command. This time as you can see the value is set as yes . It means allow root user for remote SSH authentication.
root@localhost:~# grep -i permitrootlogin /etc/ssh/sshd_config PermitRootLogin yes # the setting of "PermitRootLogin without-password".
Step 3: Restart SSH service
After setting the parameter, you need to restart ssh service by using systemctl restart ssh command as shown below.
root@localhost:~# systemctl restart ssh
Then check the service status by using systemctl status ssh command. It should show as active and running as you can see below.
root@localhost:~# systemctl status ssh ● ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2021-11-05 09:03:42 IST; 12min ago Docs: man:sshd(8) man:sshd_config(5) Process: 3873 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS) Main PID: 3875 (sshd) Tasks: 1 (limit: 2312) Memory: 2.5M CGroup: /system.slice/ssh.service └─3875 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
Step 4: Login with root
Now you can try login with root user account using putty or any other SSH tools you are using. Here we are using putty application so we will connect our Server by providing its IP Address 192.168.29.113 . It will then ask for login user which will be root and then provide the root password to authenticate. It should login successfully as shown below.
Step 5: Reset root password(Optional)
Sometimes you might face Access Denied error even after changing PermitRootLogin parameter to yes and restarting the ssh service. In that situation, you can reset root user password once by using passwd command and then try with the new password.
root@localhost:~# passwd New password: Retype new password: passwd: password updated successfully
How To Allow SSH Root Login On Ubuntu 20.04
In this article you will learn How to Allow SSH Root Login on Ubuntu 20.04 LTS Linux step by step.
By default you can login as other user. SSH login as root disabled on Ubuntu for security reasons. Also By default the root doesn’t have password set on Ubuntu 20.04 Linux and you will get an error: access denied.
But root SSH login can be enabled by editing OpenSSH daemon (sshd) configuration.
WARNING! Using SSH root login is a bad idea!
Allow SSH Root Login on Ubuntu
Step 1
Login with privileged user account (or sudo su) into your Ubuntu server and open with any text editor (nano, vi, vim) sshd config file /etc/ssh/sshd_config
Step 2
Find commented PermitRootLogin parameter or manually add
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 New password: Retype new password: passwd: password updated successfully
Now you will be able SSH login as root to your Ubuntu server
Conclusion
To enable Root Login on Ubuntu edit sshd daemon configuration PermitRootLogin parameter to:
1. PermitRootLogin yes
2. Save changes
3. Restart sshd daemon
4. Set password for the root with using passwd command
Enable Root Login via SSH in Ubuntu 20.04
In this tutorial, You will learn enabling root login via SSH in Ubuntu 20.04. And we will show you how to set a password for the Root user and how to enable it. Since the Secure shell helps you to handle your network service when you may face an unsecure network, it is a logical reason to learn about it. Stay with us to verify this secure connection of client and a server. But if you have not get your own VPS, contact us to be a virtual private server owner. You can visit the packages available in Eldernode if you wish to purchase an Linux VPS server.
To let this tutorial work better, please consider the below Prerequisites:
a non-root user with sudo privileges
To set up, follow our Initial server set up on Ubuntu 20.04 LTS.
Enable Root Login via SSH in Ubuntu 20.04
By default, SSH on Ubuntu comes configured in a way that disables the root users log in. This was originally enabled as a security precaution which means that you cannot directly log in as the root user over SSH. However, you can usually get around the need for root ssh login by using the sudo command.
Set Root password
After login to Ubuntu 20.04, Now type following command for reset/set root password.
After type the command, maybe Ubuntu 20.04 check your password username. first, you put your username’s password and when you see a prompt for a new password, type a new password for root and confirm that.
you succeed to change the root password, now you need to change some configuration on /etc/ssh/ssh_config for the permit root login.
Configure SSH config to permit root login
Edit /etc/ssh/sshd_config file with following command.
As you see, the PermitRootLogin is set to No. It means that the root login via SSH has been disabled. So, to enable root login change the No to Yes . Find PermitRootLogin and delete No or without-password and type yes .
PermitRootLogin without-password
After edit the SSH config file, press Ctrl + x and press Enter 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
Now you can check SSH via Root user.
conclusion
At this point, you learned how to Enable Root Login via SSH in Ubuntu. From now on you will be able to connect to your system remotely and perform administrative tasks. So, log in to Ubuntu 20.04 via ssh with root user and enjoy it. In case you feel interested in reading more about SSH articles, have a look at Install SSH Server on Linux and allow root user login.
Click on a star to rate it!
Average rating 5 / 5. Vote count: 5
No votes so far! Be the first to rate this post.