Skip to content

Commit 73fe362

Browse files
authored
Merge pull request #2274 from github/ssh-config-windows
Fix parsing `~/.ssh/config` on Windows Thank you @VladimirUAZ for helping debug this! ❤️
2 parents 7496b3d + 2da8235 commit 73fe362

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

git/ssh_config.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"path/filepath"
77
"regexp"
88
"strings"
9+
10+
"github.com/mitchellh/go-homedir"
911
)
1012

1113
const (
@@ -15,12 +17,16 @@ const (
1517
type SSHConfig map[string]string
1618

1719
func newSSHConfigReader() *SSHConfigReader {
20+
configFiles := []string{
21+
"/etc/ssh_config",
22+
"/etc/ssh/ssh_config",
23+
}
24+
if homedir, err := homedir.Dir(); err == nil {
25+
userConfig := filepath.Join(homedir, ".ssh", "config")
26+
configFiles = append([]string{userConfig}, configFiles...)
27+
}
1828
return &SSHConfigReader{
19-
Files: []string{
20-
filepath.Join(os.Getenv("HOME"), ".ssh/config"),
21-
"/etc/ssh_config",
22-
"/etc/ssh/ssh_config",
23-
},
29+
Files: configFiles,
2430
}
2531
}
2632

0 commit comments

Comments
 (0)