I am writing a script that
1. ssh to a host
2. issue a sudo command in that hose to change from user1 to user2 (so sudo -H -u user2 bash)
3. execute a script as user 2 in bash
I have tried
So in summary, I need this script 1 executed as user2.
I am trying to get this done in user2 in bash, instead of soemthing like
is there any way I can accomplish this?
1. ssh to a host
2. issue a sudo command in that hose to change from user1 to user2 (so sudo -H -u user2 bash)
3. execute a script as user 2 in bash
I have tried
Code:
scp script1.sh $host:~/
ssh $host <<END_SCRIPT
sudo -H -u user2 bash
./script1.sh
exit
END_SCRIPT
So in summary, I need this script 1 executed as user2.
I am trying to get this done in user2 in bash, instead of soemthing like
Code:
sudo -H -u user2 ./script1
is there any way I can accomplish this?