if user == "" {
user = s.config.SshUser
}
- err := conn.DialSSH(user, s.host.Name, s.config.SshConfig)
+ err := conn.DialSSH(rpc.SSHConfig{
+ Host: s.host.Name,
+ User: user,
+ SshConfig: s.config.SshConfig,
+ })
if err != nil {
return err
}
"ruderich.org/simon/safcm/remote"
)
-func (c *Conn) DialSSH(user, host, sshConfig string) error {
+type SSHConfig struct {
+ Host string
+ User string // optional
+ SshConfig string // optional
+}
+
+func (c *Conn) DialSSH(cfg SSHConfig) error {
if c.events == nil {
return fmt.Errorf("cannot reuse Conn")
}
- remote := host
- if user != "" {
- remote = user + "@" + host
+ remote := cfg.Host
+ if cfg.User != "" {
+ remote = cfg.User + "@" + cfg.Host
}
c.debugf("DialSSH: connecting to %q", remote)
}
c.sshRemote = remote
- if sshConfig != "" {
- c.sshOpts = []string{"-F", sshConfig}
+ if cfg.SshConfig != "" {
+ c.sshOpts = []string{"-F", cfg.SshConfig}
}
c.cmd = exec.Command("ssh",
append(append([]string{}, c.sshOpts...),