diff --git a/ssh/client.go b/ssh/client.go index 03c4e77..e607610 100644 --- a/ssh/client.go +++ b/ssh/client.go @@ -82,11 +82,11 @@ func NewClientConn(c net.Conn, addr string, config *ClientConfig) (Conn, <-chan // clientHandshake performs the client side key exchange. See RFC 4253 Section // 7. func (c *connection) clientHandshake(dialAddress string, config *ClientConfig) error { - c.clientVersion = []byte(packageVersion) if config.ClientVersion != "" { c.clientVersion = []byte(config.ClientVersion) + } else { + c.clientVersion = []byte(packageVersion) } - var err error c.serverVersion, err = exchangeVersions(c.sshConn.conn, c.clientVersion) if err != nil { diff --git a/ssh/server.go b/ssh/server.go index 8c4f142..ee2eeab 100644 --- a/ssh/server.go +++ b/ssh/server.go @@ -65,6 +65,11 @@ type ServerConfig struct { // AuthLogCallback, if non-nil, is called to log all authentication // attempts. AuthLogCallback func(conn ConnMetadata, method string, err error) + + // ServerVersion is the version identification string to + // announce in the public handshake. + // If empty, a reasonable default is used. + ServerVersion string } // AddHostKey adds a private key as a host key. If an existing host @@ -163,8 +168,12 @@ func (s *connection) serverHandshake(config *ServerConfig) (*Permissions, error) return nil, errors.New("ssh: server has no host keys") } + if config.ServerVersion != "" { + s.serverVersion = []byte(config.ServerVersion) + } else { + s.serverVersion = []byte(packageVersion) + } var err error - s.serverVersion = []byte(packageVersion) s.clientVersion, err = exchangeVersions(s.sshConn.conn, s.serverVersion) if err != nil { return nil, err