Skip to content

Commit ee6e1cb

Browse files
selzocaramprice
authored andcommitted
Refactor ssh option passing
ai-assisted=yes [TNZ-94640] Signed-off-by: Aram Price <aram.price@broadcom.com>
1 parent e786ee9 commit ee6e1cb

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

ssh/ssh_args.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func NewSSHArgs(connOpts ConnectionOpts, result boshdir.SSHResult, forceTTY bool
5656
}
5757

5858
func (a SSHArgs) LoginForHost(host boshdir.Host) []string {
59-
return []string{host.Host, "-l", host.Username}
59+
return []string{"-l", host.Username, "--", host.Host}
6060
}
6161

6262
func formProxyOpt(existenceChecker cmdExistenceChecker, proxyHostString string) string {

ssh/ssh_args_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ var _ = Describe("SSHArgs", func() {
4444
return SSHArgs{}.LoginForHost(host)
4545
}
4646

47-
It("returns login details with IPv4", func() {
48-
Expect(act()).To(Equal([]string{"127.0.0.1", "-l", "user"}))
47+
It("returns login details with IPv4, placing '--' before host to stop option parsing", func() {
48+
Expect(act()).To(Equal([]string{"-l", "user", "--", "127.0.0.1"}))
4949
})
5050

51-
It("returns login details with IPv6 non-bracketed", func() {
51+
It("returns login details with IPv6, placing '--' before host to stop option parsing", func() {
5252
host.Host = "::1"
53-
Expect(act()).To(Equal([]string{"::1", "-l", "user"}))
53+
Expect(act()).To(Equal([]string{"-l", "user", "--", "::1"}))
5454
})
5555
})
5656

0 commit comments

Comments
 (0)