1

I have a VPS with Ubuntu 14.04. I need to login as root to my server over SSH.

I set a password for root: sudo passwd root
then enabled it: sudo passwd -u root
then rebooted my vps: sudo reboot

But I still can't connect with the root user. How can i enable ssh login as root?

belacqua
  • 23,540

4 Answers4

7

The default on Ubuntu 14.04 in /etc/ssh/sshd_config is

PermitRootLogin without-password

which forbids root logins using password authentication. This is a good idea because brute-force login attempts against the root user are extremely common.

To login as root, I recommend setting up key-based SSH login. Another (dangerous!) possibility is to change the option to PermitRootLogin yes.

muru
  • 207,228
2

This doesn't answer the question directly, but if your intent is simply to administer your machine remotely, it is generally considered preferable and safer to log in as a non-root user, then elevate your privileges once you have started a session on the server.

In other words, instead of using ssh root@yourserver, you may wish to log in as yourself (your own distinct username and account) then run sudo bash or even su and to authenticate as root once logged in. You can also prepend most commands with sudo to have that command run with root's privilege level, e.g.,:

sudo cp /etc/configthing.conf /etc/configthing.conf.orig or

sudo rm -i /var/log/syslog.3.gz

belacqua
  • 23,540
Jagarti
  • 63
1

If you insist on having to log in as root, I'd suggest logging in as a normal user, running

sudo tail -f /var/log/auth.log

and then (without closing that session), trying to log in as root via SSH and observe the authentication error messages appearing in the first session.

You should be able to figure out the reason you're unable to log in as root from there, otherwise posting /etc/ssh/sshd_config might get you an answer more quickly.

0

There are many examples online so I will not repeat them.

The one thing they do not say is you need:

ssh-add [path_to_key]

when using a custom name (not default) for the key.

If you insist on only using a password not a public-private key pair:

ssh root@server-ip-or-hostname

and type your pass.

BAR
  • 101