How to execute a shell script in remote server

In remote server create your file. On the top of your file add

 #!/bin/bash

Now, make your file executable

 sudo chmod +x script.sh 

Invoke the shell script in the server remotely

 ssh  user@ip   'sudo -n /home/user/script.sh' 

1 thought on “How to execute a shell script in remote server”

Leave a Reply

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