diff options
author | Robert Smith <smith.rob.s@gmail.com> | 2017-12-09 18:29:56 -0500 |
---|---|---|
committer | Robert Smith <smith.rob.s@gmail.com> | 2017-12-09 18:29:56 -0500 |
commit | 479d38ba02f553550c6cd2b7133a1a140a361080 (patch) | |
tree | 1c26554ea1231e6483f6fa5b5eade36bd2d9e89a /plumbing/transport/ssh/common.go | |
parent | a955b6f6f3e3cf37d284dca64c8335873ff9e3be (diff) | |
download | go-git-479d38ba02f553550c6cd2b7133a1a140a361080.tar.gz |
check .ssh/config for host and port overrides; fixes #629
Diffstat (limited to 'plumbing/transport/ssh/common.go')
-rw-r--r-- | plumbing/transport/ssh/common.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/plumbing/transport/ssh/common.go b/plumbing/transport/ssh/common.go index f5bc9a7..872379a 100644 --- a/plumbing/transport/ssh/common.go +++ b/plumbing/transport/ssh/common.go @@ -4,11 +4,13 @@ package ssh import ( "fmt" "reflect" + "strconv" "gopkg.in/src-d/go-git.v4/plumbing/transport" "gopkg.in/src-d/go-git.v4/plumbing/transport/internal/common" "golang.org/x/crypto/ssh" + "github.com/kevinburke/ssh_config" ) // DefaultClient is the default SSH client. @@ -122,7 +124,20 @@ func (c *command) connect() error { func (c *command) getHostWithPort() string { host := c.endpoint.Host + + configHost := ssh_config.Get(host, "Hostname") + if (configHost != "") { + host = configHost + } + port := c.endpoint.Port + configPort := ssh_config.Get(host, "Port") + if (configPort != "") { + i, err := strconv.Atoi(configPort) + if err != nil { + port = i + } + } if port <= 0 { port = DefaultPort } |