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

Diogo Gomes
  • 121
  • 6
d0min0r4bb1t
  • 443
  • 1
  • 4
  • 6
  • 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 '21 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 '22 at 16:25

4 Answers4

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

MadAntrax
  • 921
  • 7
  • 8
  • 5
    Note that if the PermitRootLogin line starts with a comment sign (#) you have to remove that sign! – gosuto Apr 27 '18 at 07:17
  • 1
    I was helped the last line to set root password. Thanks. – Andrei Krasutski Aug 21 '18 at 07: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 Mar 12 '24 at 06: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 Mar 25 '24 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.

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • 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 '16 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 Mar 25 '24 at 10:19
3

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

 sudo su -

to switch to root

南山竹
  • 131
  • 2
-1

You can

sudo su

Then use passwd to change the password

Steve Robillard
  • 34,687
  • 17
  • 103
  • 109
Alex
  • 11