Fix ipv6 parsing for builtin ssh server (#17561)

This commit is contained in:
Wim 2021-11-06 07:23:32 +01:00 committed by GitHub
parent 5e0cf4b82e
commit bd613c704c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View file

@ -17,6 +17,7 @@ import (
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"sync"
"syscall"
@ -264,7 +265,7 @@ func sshConnectionFailed(conn net.Conn, err error) {
// Listen starts a SSH server listens on given port.
func Listen(host string, port int, ciphers []string, keyExchanges []string, macs []string) {
srv := ssh.Server{
Addr: fmt.Sprintf("%s:%d", host, port),
Addr: net.JoinHostPort(host, strconv.Itoa(port)),
PublicKeyHandler: publicKeyHandler,
Handler: sessionHandler,
ServerConfigCallback: func(ctx ssh.Context) *gossh.ServerConfig {