How to change user to root in an SFTP client?
Solution 1:
No, it is not possible to elevate your privileges within sftp.
Ideally you should fix the filesystem permission so that don't need root privileges to download/upload whatever you are working on.
If changing permissions isn't an option, then there is a compromise between disabling root logins, and logins with a password. You could set PermitRootLogin without-password
and then simply use key-based authentication.
Solution 2:
It's not completely true that you cannot change the user with SFTP.
For example, even if you are connecting to the common OpenSSH server, you can instruct it to run the SFTP subsystem/server with elevated privileges using a SFTP server startup command like:
sudo /path/to/sftp-server
For example with OpenSSH sftp
client you can use something like:
sftp -s "sudo /path/to/sftp-server" [email protected]
Or with (my) WinSCP SFTP client you can also override the SFTP server start command (both in GUI and scripting).
But there's lot of limitations to allow this working. Particularly the sudo
may not require password and TTY. For details, see WinSCP FAQ How do I change user after login (e.g. su root)?