I’m going to assume you can already sudo to the user in question …
… in WinSCP setup for a new site:
- New Site
- Session: File protocol: SCP
- Session: host name: my-host-name
- Session: user name: MY-user-name
- CLICK Advanced… BUTTON
- Advanced: left-hand-navigator select SCP/Shell
Advanced:Shell: MAGIC-HAPPENS-HERE The “pick list” for Shell has “Default” selected. You will enter TEXT here…
/usr/bin/sudo -u TARGET-user-name -i
(above command varies by unix distro)
- NO-OTHER-CHANGES to the default settings, just select OK to close the Advanced window and save your changes.
….. this should be all you need!
There is a FAQ for this question on WinSCP site:
How do I change user after login (e.g. su root)?
You need to specify the
sudo command in WinSCP session settings, as a custom shell (if you are using SCP) or use the
sudo in a custom SFTP server startup command (if you are using SFTP).
Though there are some limitations, notably that you need to configure the
sudo not to require a password.
See the link for details.