13

I'm using WinSCP to access Unix computers. How can I change user after I have logged into a Unix server using WinSCP?

E.g. I have personal account in Unix computer A. I can log into this computer using PuTTY and then change user to root user

$sudo /usr/bin/su - rootuser

How can I do the same thing using WinSCP? I don't know the password for rootuser.

3 Answers 3

7

I'm going to assume you can already sudo to the user in question ... ... in WinSCP setup for a new site:

  1. New Site
  2. Session: File protocol: SCP
  3. Session: host name: my-host-name
  4. Session: user name: MY-user-name
  5. CLICK Advanced... BUTTON
  6. Advanced: left-hand-navigator select SCP/Shell
  7. 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)

  1. 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!

6

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.

0
0

For SCP, What works for me, using WinSCP to connect to Ubuntu system as rootuser:

Put this as shell

sudo -su rootuser

enter image description here

0

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.