34

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

2
  • 1
    It is possible. But is it wise to allow remote root login? Most people are better off leaving remote root login disabled and using sudo, when required. A sensibly secure default has been chosen for a reason.
    – moo
    Jul 12, 2021 at 18:57
  • Is a there a counterpart to sudo when you want to ftp? if not I have a valid reason to login as root from filezilla and use my favorite editor on my PC to edit any file on the bloody raspberry pi. I don't want to use the crap nano, emacs, vi, ...etc :) it's backwards.
    – Meryan
    Jan 26, 2022 at 16:25

4 Answers 4

59

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

2
  • 5
    Note that if the PermitRootLogin line starts with a comment sign (#) you have to remove that sign!
    – gosuto
    Apr 27, 2018 at 7:17
  • 1
    I was helped the last line to set root password. Thanks. Aug 21, 2018 at 7:12
7

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.

1
  • 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).
    – stevieb
    Sep 30, 2016 at 14:24
3

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

 sudo su -

to switch to root

1
  • For ssh that's fine, the main problem was winscp where I can't just use sudo May 29, 2016 at 12:05
-1

You can

sudo su

Then use passwd to change the password

Not the answer you're looking for? Browse other questions tagged or ask your own question.