Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 479d38b

Browse files
committed
check .ssh/config for host and port overrides; fixes #629
1 parent a955b6f commit 479d38b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

plumbing/transport/ssh/common.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ package ssh
44
import (
55
"fmt"
66
"reflect"
7+
"strconv"
78

89
"gopkg.in/src-d/go-git.v4/plumbing/transport"
910
"gopkg.in/src-d/go-git.v4/plumbing/transport/internal/common"
1011

1112
"golang.org/x/crypto/ssh"
13+
"github.com/kevinburke/ssh_config"
1214
)
1315

1416
// DefaultClient is the default SSH client.
@@ -122,7 +124,20 @@ func (c *command) connect() error {
122124

123125
func (c *command) getHostWithPort() string {
124126
host := c.endpoint.Host
127+
128+
configHost := ssh_config.Get(host, "Hostname")
129+
if (configHost != "") {
130+
host = configHost
131+
}
132+
125133
port := c.endpoint.Port
134+
configPort := ssh_config.Get(host, "Port")
135+
if (configPort != "") {
136+
i, err := strconv.Atoi(configPort)
137+
if err != nil {
138+
port = i
139+
}
140+
}
126141
if port <= 0 {
127142
port = DefaultPort
128143
}

0 commit comments

Comments
 (0)