Reputation: 13128
I need to execute shell script on my remote linux machine. Do you know any tools that can help me doing that?
Thanks,
Upvotes: 2
Views: 1544
Reputation: 281
ssh remotePassword@remoteHost < localScript.sh
ssh remotePassword@remoteHost "remoteScript.sh"
Upvotes: 0
Reputation: 3068
You can connect through ssh passing a command as a parameter:
ssh [email protected] "~/myscript.sh"
To connect without password, use ssh keys. To use keys, you have to generate a pair at your machine, with the command:
ssh-keygen
Then take the contents of the file ~/.ssh/id_rsa.pub (or id_dsa.pub if you use parameter -t dsa in ssh-keygen) and put in the file ~/.ssh/authorized_keys of the remote_machine. The .ssh dir must have permission 700.
Upvotes: 3
Reputation: 4193
Passwordless remote execution without waiting for remote script to complete before terminating the ssh connection:
ssh -i ~/.ssh/id_rsa user@remote nohup sh /path/to/script.sh > /dev/null 2>&1 &
Upvotes: 0