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

Logging ssh bastion #123

Merged
merged 2 commits into from Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions communicator/config.go
Expand Up @@ -547,10 +547,10 @@ func (c *Config) prepareSSH(ctx *interpolate.Context) []error {
}
}

if c.SSHBastionHost != "" && !c.SSHBastionAgentAuth {
if c.SSHBastionPassword == "" && c.SSHBastionPrivateKeyFile == "" {
if c.SSHBastionHost != "" {
if c.SSHBastionPassword == "" && c.SSHBastionPrivateKeyFile == "" && !c.SSHBastionAgentAuth {
errs = append(errs, errors.New(
"ssh_bastion_password or ssh_bastion_private_key_file must be specified"))
"ssh_bastion_password, ssh_bastion_private_key_file or ssh_bastion_agent_auth must be specified"))
} else if c.SSHBastionPrivateKeyFile != "" {
path, err := pathing.ExpandUser(c.SSHBastionPrivateKeyFile)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions communicator/step_connect_ssh.go
Expand Up @@ -165,6 +165,8 @@ func (s *StepConnectSSH) waitForSSH(state multistep.StateBag, ctx context.Contex
var connFunc func() (net.Conn, error)
address := fmt.Sprintf("%s:%d", host, port)
if bAddr != "" {
log.Printf("[INFO] connecting with SSH to host %s through bastion at %s",
address, bAddr)
// We're using a bastion host, so use the bastion connfunc
connFunc = ssh.BastionConnectFunc(
bProto, bAddr, bConf, "tcp", address)
Expand Down
4 changes: 4 additions & 0 deletions sdk-internals/communicator/ssh/connect.go
Expand Up @@ -2,6 +2,7 @@ package ssh

import (
"fmt"
"log"
"net"
"time"

Expand Down Expand Up @@ -62,6 +63,9 @@ func BastionConnectFunc(
return nil, fmt.Errorf("Error connecting to bastion: %s", err)
}

log.Println("[DEBUG] connected to bastion host")
log.Println("[DEBUG] attempting connection to destination host")

// Connect through to the end host
conn, err := bastion.Dial(proto, addr)
if err != nil {
Expand Down