To switch user we use su command which stand for substitute user
su root
#a prompt will ask for password
Most of the time linux OS comes with the user account which may not have root permissions so to switch to root simply type su or su root .
If you are trying to login with root for the first time from user's account, you will need to set password first. In order to do that
sudo passwd root
# Enter password
# Re-enter password
Simply adding a password for root is not enough, you'll also need to edit sshd_config
, and set PermitRootLogin from prohibit-password to yes:
nano etc/ssh/sshd_config
# Authentication:
LoginGraceTime 120
# PermitRootLogin prohibit-password
PermitRootLogin yes
StrictModes yes
Now restarting ssh service
systemctl restart sshd
and voilĂ it's done.