Depending on your SSH configuration (usually defined in
/etc/ssh/sshd_config) root access may be disabled in a number of ways:
- No root access at all (
- root is allowed access, but only via key-pair authentication (
- root access is allowed, but only specific commands can be executed (
- root is allowed, but only via specific ACLs which can restrict from where, whom and to which users they can access ssh (such as
- tcpwrappers have been used, and there are entries in
/etc/hosts.deny which restrict ssh access.
- You are not using the correct protocol with your client (v1 vs. v2 set with
Protocol 2), though this is unlikely.
There are a few routes to gaining root access. First of all try connecting to the ssh daemon from different host locations (using ssh to root@localhost on the machine itself, or connecting to its public IP address from an external host). Next you can try using
su to gain root access with the command
su - root (some operating systems enforce your user to be in the
wheel group to do this) - this command expects you to provide the root users' password. You can also try
sudo, if it is installed and configured to give your user root access (
sudo bash), which expects the password of the account using the sudo command (or no password at all if sudo is configured that way).
If none of these work, the next thing would to go down the route of rebooting your operating system in single user mode and trying your root password there. If that still doesn't work then you probably need to reset the root password and will have to boot from a recovery or live CD and reset the password that way.
Once you have gained root access, the configuration can be tweaked by checking the settings mentioned above to assure future ssh access. Remember to SIGHUP (
killall -SIGHUP sshd) or restart the ssh daemon if you make configuration changes.