There could be multiple causes here.
First, many Linux distributions come, or at least suggest that you lock out the root
user from ssh
. This is because every system comes with root
, and it makes it easier to brute-force a machine if you're aware of a user. Not a foolproof, but helpful.
Otherwise, you need to understand that each user has their own password, and it is the password of that user, and the entries found for sudo
in /etc/sudoers
, that allow a user to successfully execute a command with sudo
.
To clarify, when you use this command, you are using the USER password:
sudo su -i
sudo
checks if you're allowed to run the command, and also prompts you for your USER password.
When you log into a machine, you use that USER password again. It is unlikely, and a bad practice, to have your USER and your root account share passwords. In this case, since you know the USER password, you would do the following:
ssh USER@myserver
sudo su -
Here, you access the system using the USER account, and known password, and then escalate to root. This solves either problem, and is how you should be escalating to root.
If you discover that your server allows root login, but you were using the password incorrectly, be sure to lock that down. Other Answers to your question are suggesting you allow root login, but instead, I ask that you understand the situation, and stay secure by following this advice instead. Look up ssh
hardening, and at least set up fail2ban
.
root
, while the user has a proper user withsudo
privileges already. This does not address the problem, but instead provides a workaround that needlessly increases risk and supports bad practice. – earthmeLon May 12 '18 at 23:40josh
overroot
, but you're right, you're at a security disadvantage by allowing escalation without a password, and these things start to add up. – earthmeLon May 13 '18 at 02:40