I need to perform some operation in a remote machine in which first I login as userA then change to userB
ssh userA@remoteHost
userA$ 'sudo su userB'
Type password of userA to change to userB. Do other operations as userB
I want to achieve this by running a script from my local machine to the remote machine.
localUser$ ssh userA@remoteHost 'bash -s' < script
Inside the script, some thing like this :
#!/bin/bash
sudo su userB
....
perform other operations as userB
At this moment when I run this script it asks for userA password to run the script first. Then asks for password for userA to switch to userB. But I am not able to input anything as the prompts do not persist. How to achieve this ?