Skip to content

Commit 1bbd7f5

Browse files
committed
sshutil: specify username explicitly
Fix #85 Signed-off-by: Akihiro Suda <[email protected]>
1 parent eec5682 commit 1bbd7f5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/sshutil/sshutil.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66
"os/exec"
7+
"os/user"
78
"path/filepath"
89
"strings"
910

@@ -68,11 +69,16 @@ func RemoveKnownHostEntries(sshLocalPort int) error {
6869
}
6970

7071
func SSHArgs(instDir string) ([]string, error) {
72+
u, err := user.Current()
73+
if err != nil {
74+
return nil, err
75+
}
7176
controlSock := filepath.Join(instDir, filenames.SSHSock)
7277
if len(controlSock) >= osutil.UnixPathMax {
7378
return nil, errors.Errorf("socket path %q is too long: >= UNIX_PATH_MAX=%d", controlSock, osutil.UnixPathMax)
7479
}
7580
args := []string{
81+
"-l", u.Username, // guest and host have the same username, but we should specify the username explicitly (#85)
7682
"-o", "ControlMaster=auto",
7783
"-o", "ControlPath=" + controlSock,
7884
"-o", "ControlPersist=5m",

0 commit comments

Comments
 (0)