Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you execute a command on a remote system insde a BASH script?

As part of an intricate BASH script, I'd like to execute a command on a remote system from within the script itself.

Right now, I run the script which tailors files for the remote system and uploads them, then through a ssh login I execute a single command.

So for full marks:

  • How do I log into the remote system from the bash script (i.e. pass the credentials in non-interactively)?
  • How can I execute a command (specifically "chmod 755 /go && /go") from within the script?
like image 925
Jamie Avatar asked Oct 14 '22 16:10

Jamie


1 Answers

Following Tim Post's answer:

Setup public keys and then you can do the following:

#!/bin/bash
ssh user@host "chmod 755 /go && /go"
like image 57
Jeremy L Avatar answered Oct 18 '22 12:10

Jeremy L