I want to download files from a linux system using a windows client. While there are many SFTP clients I am having the problem, that I need to access files where I need to be root. On the linux system I have the root account disabled, I am using sudo to get root privileges. How to execute "sudo" using an SFTP client? I don't want to change my linux system! Thanks for any hint!


As sftp does not run commands you'd have to run the sftp module itself with sudo. But as there is no terminal attached after you logged in you must be able to run sudo without a password.

For a detailed howto with WinSCP have a look at https://winscp.net/eng/docs/faq_su#sudo


If your server only allows the SFTP protocol, you can't combine that with sudo, you'll have to find another method. If your server allows arbitrary shell commands, you can use sudo, but most file transfer programs don't have a feature to invoke it and pass it a password.

One client that does allow combining ssh with sudo to access files is Emacs (through Tramp, which is built into Emacs since version 23). See Open file via SSH and Sudo with Emacs. You can use dired (also a built-in Emacs feature) to manage files.

It would be more convenient to use SSH to become root. If you use a password-protected key that is only accepted from localhost, the security is equivalent to a standard sudo setup. See Copying protected files between servers in one line?

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.