Thanks for the reply! When I login to that computer, and I execute "sudo su - user2", it does not prompt for password.
In your command, that would require password of user1, and then enter the remote computer. What I had in mind is a set of commands that I can put in a script file and just execute that file and when it returns, the prompt is still on my local computer.
I have tried:
Code:
ssh user1@10.22.10.111 'sudo su - user2 && cp /tmp/file.txt /home/user2/'
but doesn't work and I ended up in the remote computers terminal logged as user2. and when I exit, i got the file permission failed error.