Sobes.tech
Junior — Middle

How can you establish a remote SSH connection under another user's account?

sobes.tech AI

Answer from AI

To establish an SSH connection under a different user's account, you can use the -l option or specify the user before the host address:

ssh -l username remote_host
# or
ssh username@remote_host

If you have access to the current user but need to switch to another user on the remote machine, you can execute:

ssh current_user@remote_host 'sudo -i -u other_user'

This will require the password of other_user or sudo configuration without a password. You can also use SSH keys configured for the target user for direct login without a password.