How to login as root remotely?

  • I am trying to login to the raspberrypi as root user via winscp, but it only says "Access denied", same thing for trying to login directly as root on ssh.

    I have tried loging in as pi and doing sudo passwd root, which results in the console output passwd: Password changed successfully, however I still can't login as root

  • MadAntrax

    MadAntrax Correct answer

    4 years ago

    If you want to login as root using SSH or WinSCP you need to edit the config of SSHD, do this:

    • Login, and edit this file: sudo nano /etc/ssh/sshd_config
    • Find this line: PermitRootLogin without-password
    • Edit: PermitRootLogin yes
    • Close and save file
    • reboot or restart sshd service using: /etc/init.d/ssh restart
    • Set a root password if there isn't one already: sudo passwd root

    Now you can login as root, but I recommend you using strong password or ssh-keys

    Note that if the `PermitRootLogin` line starts with a comment sign (`#`) you have to remove that sign!

    I was helped the last line to set root password. Thanks.

  • You cannot login as root because Raspbian does not have a root password. See Raspbian root default password

    Normally ssh does not allow root access because this is considered a security risk. You should be able to do everything you need using sudo (which is the normal Debian practice).

    If you REALLY want ssh root access it can be enabled.

    I'm very glad someone at least pointed out that this is a security risk. SSH as root is never a good idea (particularly when using password auth).

  • You can login as normal user (belong sudoer group) then

     sudo su -

    to switch to root

    For ssh that's fine, the main problem was winscp where I can't just use sudo

  • You can

    sudo su

    Then use passwd to change the password

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM