09 Feb

Execute command on remote machine as different user via SSH

Execute command on remote machine as different user via SSH

To execute command on remote machine as different user via SSH, you may need to run the below command

In our example, we are executing the script.sh as root after login to the server as testuser

If you are trying to execute a command to action a file on remote machine as a different user, you need to run the below command,

In our example, we are executing the script.sh as root after login to the server as testuser

If you wish to reboot a remote server as a different user, please execute,

To execute multiple commands via SSH, please execute,

Example script below,

 

Leave a Reply

Your email address will not be published. Required fields are marked *

four + 4 =