SFTP and sudo using Windows client?

11,852

Solution 1

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

Solution 2

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?

Share:
11,852

Related videos on Youtube

Nik
Author by

Nik

Updated on September 18, 2022

Comments

  • Nik
    Nik almost 2 years

    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!