In many Linux environments, you might have access to a privileged user (like podadmin
) only through sudo
— for example, from a user like uday
via:
sudo su - podadmin
This works fine in a terminal (e.g., PuTTY), but what if you want to connect as podadmin
using WinSCP — and you don’t know podadmin
's password?
Here’s how you can do it.
🛠️ Problem Setup
-
You can log in as user, and from there
sudo su - podadmin
. -
You do not have the password for
podadmin
. -
You want to transfer files as
podadmin
using WinSCP.
✅ Solution: Use uday
in WinSCP and Auto-Switch to podadmin
Step 1: Open WinSCP and Set Up a New Session
-
In the Session tab:
-
File protocol: SCP
-
Host name: your server's IP or hostname
-
User name:
user
-
Password: your
uday
password
-
-
Click Advanced...
-
Go to Environment > SCP/Shell
-
Set Shell to:
sudo su - podadmin
-
Save the session and connect.
🔒 Optional: Enable Passwordless Sudo (for a smoother experience)
By default, WinSCP can't interactively enter a sudo
password. To make it work, you can configure passwordless sudo
access for user
to become podadmin
.
Steps:
-
SSH into the server as root or a user with sudo access.
-
Run:
sudo visudo
-
Add this line at the end:
user ALL=(podadmin) NOPASSWD: ALL
Now, user
can switch to podadmin
without entering a password — perfect for automated tools like WinSCP.
🚀 Done!
You can now use WinSCP to connect as user
, and it will automatically switch to podadmin
on login. You’ll be able to access and transfer files as if you were podadmin
, without needing their password.
No comments:
Post a Comment