KItis
KItis

Reputation: 5646

Switching users using WinSCP between different accounts

Is there way to switch between user accounts using WinSCP?

When I am using PuTTY, I can use su command to switch users between different accounts.

For an example:

kitis@localhost$
kitis@localhost$ su abc
abc@localhost$

In the same way, when I am using WinSCP, is there a way for me to switch users while I have logged in to a server?

Upvotes: 6

Views: 31437

Answers (4)

Inny
Inny

Reputation: 13

In 2024, if you're trying to do this on Ubuntu 22, you will find the following works for SFTP:

Go to: Profile Manager > Edit Profile > Advanced > Advanced Site Settings > Environment > SFTP (not Shell) > SFTP server:

sudo su <username> -c /usr/lib/openssh/sftp-server

Note that the user you're trying to su to must have a valid shell assigned (such as /bin/bash), it's specified in the last field for the user in /etc/passwd. If you are running into any issues, make sure you are able to su from a regular SSH session first.

Upvotes: 0

If the user has sudo to another user via SSH. The same sudo to another user works via WinSCP following the below settings. In File Protocol select SCP, pass the hostname, username, and password/key and in advanced settings under SCP/Shell in Shell pass the value as /usr/bin/sudo -u username -i, click on ok and save the settings. Now in Winscp, the user is logged in as the username provided in SCP/Shell.

Upvotes: 2

Martin Prikryl
Martin Prikryl

Reputation: 202494

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 custom shell (if you are using SCP) or use sudo in custom SFTP server startup command (if you are using SFTP).

Though there are some limitations, notably that you need to configure sudo not to require a password.

See the link for details.

Upvotes: 8

Igor Chubin
Igor Chubin

Reputation: 64603

No, it is impossible. When you want to switch user using SCP (WinSCP in your case) your need to relogin. You can't run any commands in SCP-session, just manage files; fnd SCP-protocol itself supports no mechanisms to change current users' id. You must use SSH if you want to have a possibility to change a user in a session.

Upvotes: 1

Related Questions