Difference between revisions of "Golang ssh"
Jump to navigation
Jump to search
(Created page with "https://stackoverflow.com/questions/37679939/how-do-i-execute-a-command-on-a-remote-machine-in-a-golang-cli ``` package main import ( "bytes" "log" "os/exec" )...") |
(No difference)
|
Latest revision as of 21:39, 8 December 2020
package main import ( "bytes" "log" "os/exec" ) func main() { cmd := exec.Command("ssh", "remote-machine", "bash-command") var out bytes.Buffer cmd.Stdout = &out err := cmd.Run() if err != nil { log.Fatal(err) } } To jump over machines use the ProxyCommand directive in a ssh config file. Host remote_machine_name ProxyCommand ssh -q bastion nc remote_machine_ip 22