From 056be87c2dc18a75bd0d25810bb4f8f60a908cef Mon Sep 17 00:00:00 2001 From: Brendan Date: Mon, 28 Nov 2016 11:08:40 +1100 Subject: [PATCH] Add support for ssh password authentication --- ssh.go | 2 ++ sup.go | 9 ++++++--- supfile.go | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ssh.go b/ssh.go index dba3f26..ea88885 100644 --- a/ssh.go +++ b/ssh.go @@ -19,6 +19,7 @@ type SSHClient struct { conn *ssh.Client sess *ssh.Session user string + password string host string remoteStdin io.WriteCloser remoteStdout io.Reader @@ -137,6 +138,7 @@ func (c *SSHClient) ConnectWith(host string, dialer SSHDialFunc) error { User: c.user, Auth: []ssh.AuthMethod{ authMethod, + ssh.Password(c.password), }, } diff --git a/sup.go b/sup.go index d528162..a7af6d7 100644 --- a/sup.go +++ b/sup.go @@ -40,7 +40,9 @@ func (sup *Stackup) Run(network *Network, envVars EnvList, commands ...*Command) // Create clients for every host (either SSH or Localhost). var bastion *SSHClient if network.Bastion != "" { - bastion = &SSHClient{} + bastion = &SSHClient{ + password: network.Password, + } if err := bastion.Connect(network.Bastion); err != nil { return errors.Wrap(err, "connecting to bastion failed") } @@ -70,8 +72,9 @@ func (sup *Stackup) Run(network *Network, envVars EnvList, commands ...*Command) // SSH client. remote := &SSHClient{ - env: env + `export SUP_HOST="` + host + `";`, - color: Colors[i%len(Colors)], + env: env + `export SUP_HOST="` + host + `";`, + color: Colors[i%len(Colors)], + password: network.Password, } if bastion != nil { diff --git a/supfile.go b/supfile.go index 4f0acf5..b63c57f 100644 --- a/supfile.go +++ b/supfile.go @@ -28,6 +28,7 @@ type Network struct { Env EnvList `yaml:"env"` Inventory string `yaml:"inventory"` Hosts []string `yaml:"hosts"` + Password string `yaml:"password"` Bastion string `yaml:"bastion"` // Jump host for the environment }