aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plumbing/transport/ssh/common.go15
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
}