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
    Commented 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
    Commented 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

4
  • 5
    Note that if the PermitRootLogin line starts with a comment sign (#) you have to remove that sign!
    – gosuto
    Commented Apr 27, 2018 at 7:17
  • 1
    I was helped the last line to set root password. Thanks. Commented Aug 21, 2018 at 7:12
  • Additionally check the ownership of the authorized_keys file. My /root/.ssh/authorized_keys was owned by the wrong user and I kept getting my key rejected on login.
    – Tim
    Commented Mar 12 at 6:52
  • I have tried this but still unable to transfer a file with Putty or WinSCP to a /home/pi/docker/homeAssistant/backups folder
    – Dave
    Commented Mar 25 at 10:10
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.

2
  • 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
    Commented Sep 30, 2016 at 14:24
  • so how can I transfer a backup file to a /Home folder if I cannot have permission to my own files!
    – Dave
    Commented Mar 25 at 10:19
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 Commented 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.