I am currently logged into "SERVER1" with user "USER1", and i have placed my bash script here. This script has to switch to different user "USER2" on the same server "SERVER1" and execute some commands with the new switched user.
Note: USER1 is not a root user, so i need to specify the USER2 password inside the script, but in a encrypted format.
Please help me in achieving this..!
#!/bin/bash
command1
command2
.
.
...
echo "PASSWORD" | su USER2 << EOF
command1
command2
.
.
...
Please note, i don't want to change any configuration files here to achieve this.