Enable root user on Linux(Ubuntu/RHEL) VM provided by Azure/AWS
1. Login to the Linux machine using Password/Key authentication.
2. Set password for root user and edit sshd_config file using following command.
sudo su
passwd root -- (Enter password for root user when prompted)
sudo sed -i 's/PermitRootLogin prohibit-password/#PermitRootLogin prohibit-
password/g' /etc/ssh/sshd_config
sudo sed -i 's/PasswordAuthentication no/#PasswordAuthentication no/g'
/etc/ssh/sshd_config
sudo sed -i '$ a PermitRootLogin Yes' /etc/ssh/sshd_config
sudo sed -i '$ a PasswordAuthentication yes' /etc/ssh/sshd_config
sudo sed -i '$ a PermitRootLogin without-password' /etc/ssh/sshd_config
sudo service sshd restart (for RHEL)
passwd root -- (Enter password for root user when prompted)
sudo sed -i 's/PermitRootLogin prohibit-password/#PermitRootLogin prohibit-
password/g' /etc/ssh/sshd_config
sudo sed -i 's/PasswordAuthentication no/#PasswordAuthentication no/g'
/etc/ssh/sshd_config
sudo sed -i '$ a PermitRootLogin Yes' /etc/ssh/sshd_config
sudo sed -i '$ a PasswordAuthentication yes' /etc/ssh/sshd_config
sudo sed -i '$ a PermitRootLogin without-password' /etc/ssh/sshd_config
sudo service sshd restart (for RHEL)
2 comments:
What if 'sed' command doesn't work?
In that case you have edit the file manually
vim /etc/ssh/sshd_config
comment the lines mentioned below
------------------------------------
PermitRootLogin prohibit-password
PasswordAuthentication no
and then uncomment
---------------------------
PermitRootLogin Yes
PasswordAuthentication yes
PermitRootLogin without-password
if not there add these lines save the file :wq
and the restart the sshd service
sudo service sshd restart (for RHEL)
sudo service ssh restart (for Ubuntu)
https://osgroup-techies.blogspot.in/2017/01/password-less-authentication-on-two.html
Post a Comment