X-Git-Url: https://ruderich.org/simon/gitweb/?p=safcm%2Fsafcm.git;a=blobdiff_plain;f=rpc%2Fdial.go;h=945a75ff86c365fd1e251e205a0b68efbd2b3aef;hp=d8a63386333d2c76c27affca33418d3378bcc4dc;hb=825f928d824f728088606bcbf112d30d7a76f627;hpb=3840c3fe7fab425ef7d20d2f686884b404bb5e62 diff --git a/rpc/dial.go b/rpc/dial.go index d8a6338..945a75f 100644 --- a/rpc/dial.go +++ b/rpc/dial.go @@ -32,7 +32,7 @@ import ( "ruderich.org/simon/safcm/remote" ) -func (c *Conn) DialSSH(user, host string) error { +func (c *Conn) DialSSH(user, host, sshConfig string) error { if c.events == nil { return fmt.Errorf("cannot reuse Conn") } @@ -48,8 +48,14 @@ func (c *Conn) DialSSH(user, host string) error { // Help debugging by showing executed shell commands opts += "x" } - c.cmd = exec.Command("ssh", remote, "/bin/sh", opts) - c.remote = remote + + c.sshRemote = remote + if sshConfig != "" { + c.sshOpts = append(c.sshOpts, "-F", sshConfig) + } + c.cmd = exec.Command("ssh", + append(append([]string{}, c.sshOpts...), + c.sshRemote, "/bin/sh", opts)...) stdin, err := c.cmd.StdinPipe() if err != nil { @@ -251,10 +257,12 @@ f path = strings.TrimSuffix(path, "\n") c.debugf("DialSSH: uploading new remote to %q at %q", - c.remote, path) + c.sshRemote, path) - cmd := exec.Command("ssh", c.remote, - fmt.Sprintf("cat > %q", path)) + cmd := exec.Command("ssh", + append(append([]string{}, c.sshOpts...), + c.sshRemote, + fmt.Sprintf("cat > %q", path))...) cmd.Stdin = bytes.NewReader(helper) err = c.handleStderrAsEvents(cmd) if err != nil {