Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SSH password to Supfile #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -137,6 +138,7 @@ func (c *SSHClient) ConnectWith(host string, dialer SSHDialFunc) error {
User: c.user,
Auth: []ssh.AuthMethod{
authMethod,
ssh.Password(c.password),
},
}

Expand Down
9 changes: 6 additions & 3 deletions sup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions supfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down