Skip to content

Commit

Permalink
Fix default port for ssh
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Jul 12, 2021
1 parent 337bea3 commit c7d728f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions protocols/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,6 @@ func config(addr string) (host string, config *ssh.ClientConfig, err error) {
pwd, isPwd = ur.User.Password()
}

host, port, err := net.SplitHostPort(ur.Host)
if err != nil {
return "", nil, err
}
if port == "" {
port = "22"
}

config = &ssh.ClientConfig{
User: user,
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
Expand Down Expand Up @@ -212,5 +204,11 @@ func config(addr string) (host string, config *ssh.ClientConfig, err error) {
}
config.Auth = append(config.Auth, ssh.PublicKeys(signer))
}

host = ur.Hostname()
port := ur.Port()
if port == "" {
port = "22"
}
return net.JoinHostPort(host, port), config, nil
}

0 comments on commit c7d728f

Please sign in to comment.