I need to edit /boot/config.txt file from WinScp ssh client. In order to make changes in file I need root permissions for my login. As default pi does not have such permission and I don't have console in WinSCP in order to type sudo.

How to change file /boot/config.txt content from WinScp (or Notepad++) client?


You should use a proper SSH client like putty to get a Secure SHell on the Raspberry Pi. There you can execute all commands, also sudo.

  • But I would like to use convenient Windows editor in order to edit file that requires permission.
    – vico
    Dec 16 '20 at 11:37
  • @vico That isn't a problem belonging to Raspberry Pi. You should better asked at a MS Window$ forum.
    – Ingo
    Dec 16 '20 at 11:46

I am assuming you do not have any other users defined on the Pi.

Take the SD card out of the Pi and pop it into a Windows / Mac or Linux computer and edit it there.

The Pi OS does not come with the root user enabled so you cannot use that as the originator of the connection to work within the security.

Failing that, load a ssh client on your local computer.

  • Not necessarily a good idea because of the fact that Windoze routinely "breaks" text files due to their use of "CR-LF" line endings.
    – Seamus
    Dec 22 '20 at 20:24
  • @Seamus And MACs have a habit of changing quotes in the Apple provided GUI editor but does come with nano :-)
    – user115418
    Dec 22 '20 at 21:28

Unless you have a competent text editor on your Windows machine, you will "break" RPi's /boot/config.txt file by editing it in Windows (i.e. editing with Notepad). Here's a brief explanation of this well-known and long-standing issue.

The solutions:

  1. Use PuTTY instead of WinSCP (@Ingo's answer) so that you can edit the files in nano or one of the other text editors on the RPi.

  2. If you insist on editing the files on Windows, get a text editor that supports Unix/Linux-style line endings. See this Q&A for suggestions

  3. Wrt all of the permissions business: I don't know how WinSCP does anything, but if RPi is blocking you from uploading a revised /boot/config.txt using WinSCP, then just remove the SD card & edit it IAW #1 above. The boot partition is FAT32, so in effect there are no permissions/controls.


It's generally hard, if possible at all, to use sudo with SFTP (in any client not only in WinSCP).

But it's doable with some hacking.

The main thing is to run sftp-server via sudo in WinSCP SFTP server session setting:

sudo /path/to/sftp-server

Though sudo may need some setup to allow this.

For more details, see WinSCP FAQ How do I change user after login (e.g. su root)?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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