I need to ssh to localhost using root account, by ssh root@localhost
. When it prompts for passwords, I can not login with all possible passwords. On setting of localhost machine, regular user xxx
and root user share the same password (the password that works for sudo -s
), but it does not works for ssh root@localhost
. So where to look at the password for ssh root@localhost
PS: with the password, I can login to regular account on ssh xxx@localhost
.
PPS: to answer further questions on motivation of doing so, localhost
is just a computer in a private network and setting up ssh root@localhost
is just to relieve some manual management in a prototype system.
ssh root@localhost
uses the same password for root. It looks like you have not set root password. To do that log in as root usingsudo -s
then usepasswd
command to set root password.After that you must be able to ssh as root
If you decide to use the root account.
Disable the ability to log in over ssh with root if ssh is exposed to internet. Instead login as a user, and
su
to root.This will make sure to prevent brute force attacks against your computer. Since its harder to guess both the user and password. Knowing the username one would only have to brute force the password
changing the line:
under
/etc/ssh/sshd_config
to
and run:
to reload the configuration.
Login as a normal user and use
sudo -i
to drop to a root shell.You should not use the root account or change it's password for the matter.
The user root is not enabled and is not capable of doing a log in, you can see that doing so:
the field that usually contains an encrypted password is filled with a
!
.If you read the shadow(5) manpage you will get this
You should not enable the user root for security reasons.
set root password using following command
They answered your question about login to ssh with non super user (say
[email protected] -p 22
).First create another account without
su
privleges. After you log into ssh as a non super user you can enter this command to switch to root (escalate your privileges):And enter password.