I have the following task for my golang code:
- The command has to be run as root user on the server remotely in bash and the command output has to be fetched in a variable.
- Logging over ssh as root is disabled.
- sudo on the server is disabled, so I have to use 'su -' and type password
- since I want to make it as automated as possible in bash, the password has to be stored inside the command
Here are the workflow actions:
- Login via SSH (as unprivileged user) to remote host
- Elevate to privileged 'root' user --> su -
- Type the root password
- run the command which root can execute
- get to output to string on localhost and do some actions
I have Googled for days, but it seems that I cannot find a solution for this. Does anyone have a solution to this?