尝试使用os / exec
https://golang.org/pkg/os/exec/执行ssh
package mainimport ( "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) }}要跳过计算机,请在ssh配置文件中使用ProxyCommand指令。
Host remote_machine_name ProxyCommand ssh -q bastion nc remote_machine_ip 22



