From 5ebee843d1591b9abe2508c38d03e96d2e58d634 Mon Sep 17 00:00:00 2001 From: Ed Cook Date: Thu, 27 Aug 2020 10:04:17 +0100 Subject: [PATCH] Use configured opsman ssh username for sshuttle --- sshuttle/runner.go | 3 ++- sshuttle/runner_test.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sshuttle/runner.go b/sshuttle/runner.go index c629d8d..09a8e82 100644 --- a/sshuttle/runner.go +++ b/sshuttle/runner.go @@ -39,7 +39,8 @@ func (b Runner) Run(data environment.Config, dryRun bool, args ...string) error networksPath, cidrPath), - fmt.Sprintf(`sshuttle --ssh-cmd "ssh -o IdentitiesOnly=yes -i ${ssh_key_path}" -r ubuntu@"%s" "${cidrs}"`, + fmt.Sprintf(`sshuttle --ssh-cmd "ssh -o IdentitiesOnly=yes -i ${ssh_key_path}" -r %s@"%s" "${cidrs}"`, + data.OpsManager.SshUser, data.OpsManager.IP.String()), } diff --git a/sshuttle/runner_test.go b/sshuttle/runner_test.go index 968eb54..e5726d6 100644 --- a/sshuttle/runner_test.go +++ b/sshuttle/runner_test.go @@ -39,6 +39,7 @@ var _ = Describe("sshuttle runner", func() { url, _ := url.Parse("https://www.test-url.io") data = environment.Config{ OpsManager: environment.OpsManager{ + SshUser: "ssh_user", PrivateKey: "private-key-contents", IP: net.ParseIP("10.0.0.6"), URL: *url, @@ -68,7 +69,7 @@ var _ = Describe("sshuttle runner", func() { `trap 'rm -f ${ssh_key_path}' EXIT`, `chmod 0600 "${ssh_key_path}"`, `cidrs="$(OM_CLIENT_ID='client_id' OM_CLIENT_SECRET='client_secret' OM_USERNAME='username' OM_PASSWORD='password' om -t https://www.test-url.io -k curl -s -p /api/v0/staged/director/networks | jq -r .networks[].subnets[].cidr | xargs echo)"`, - `sshuttle --ssh-cmd "ssh -o IdentitiesOnly=yes -i ${ssh_key_path}" -r ubuntu@"10.0.0.6" "${cidrs}"`, + `sshuttle --ssh-cmd "ssh -o IdentitiesOnly=yes -i ${ssh_key_path}" -r ssh_user@"10.0.0.6" "${cidrs}"`, })) })