I'm writing a bash script which calls a lot of other scripts.
Several scripts have to be executed as user_1 but several ones as user_2.
The scripts should be called in strict sequence. I start my script as user_1 and use su many times to become user_2. These times su requires a password so I have to retype it many times.
I'd like to avoid that, but su has no password parameter.
sudo and expect are not installed.
I have solved the problem using ssh. I have generated the authentication key for user_1 and published to user2. Password is not needed any more.
ssh -l user_1 hostname "command_1; command_2"