Skip to content

Commit

Permalink
cluster/ssh: don't quote ssh options (#1469)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsvisa authored Jul 6, 2021
1 parent 4f35d3b commit 8186387
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion pkg/cluster/executor/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ func (e *NativeSSHExecutor) configArgs(args []string, isScp bool) []string {
proxyArgs = append([]string{"sshpass", "-p", proxy.Passphrase, "-P", e.prompt("passphrase")}, proxyArgs...)
}
}
args = append(args, []string{"-o", fmt.Sprintf(`ProxyCommand="%s %s@%s -p %d -W %%h:%%p"`, strings.Join(proxyArgs, " "), proxy.User, proxy.Host, proxy.Port)}...)
// Don't need to extra quote it, exec.Command will handle it right
// ref https://stackoverflow.com/a/26473771/2298986
args = append(args, []string{"-o", fmt.Sprintf(`ProxyCommand=%s %s@%s -p %d -W %%h:%%p`, strings.Join(proxyArgs, " "), proxy.User, proxy.Host, proxy.Port)}...)
}
return args
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/cluster/executor/ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestNativeSSHConfigArgs(t *testing.T) {
},
},
false,
`-o ConnectTimeout=60 -i id_rsa -o ProxyCommand="ssh -i b.id_rsa root@proxy1 -p 222 -W %h:%p"`,
"-o ConnectTimeout=60 -i id_rsa -o ProxyCommand=ssh -i b.id_rsa root@proxy1 -p 222 -W %h:%p",
},
{
&SSHConfig{
Expand All @@ -108,7 +108,7 @@ func TestNativeSSHConfigArgs(t *testing.T) {
},
},
false,
`-p 1203 -o ConnectTimeout=60 -i id_rsa -o ProxyCommand="ssh -o ConnectTimeout=10 -i b.id_rsa root@proxy1 -p 222 -W %h:%p"`,
"-p 1203 -o ConnectTimeout=60 -i id_rsa -o ProxyCommand=ssh -o ConnectTimeout=10 -i b.id_rsa root@proxy1 -p 222 -W %h:%p",
},
{
&SSHConfig{
Expand All @@ -123,7 +123,7 @@ func TestNativeSSHConfigArgs(t *testing.T) {
},
},
false,
`sshpass -p pass -P password -o ConnectTimeout=60 -o ProxyCommand="sshpass -p word -P password ssh -o ConnectTimeout=10 root@proxy1 -p 222 -W %h:%p"`,
"sshpass -p pass -P password -o ConnectTimeout=60 -o ProxyCommand=sshpass -p word -P password ssh -o ConnectTimeout=10 root@proxy1 -p 222 -W %h:%p",
},
}

Expand Down

0 comments on commit 8186387

Please sign in to comment.