From d54c6de0df5646d6ca258987145f9cd2728c3c33 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Fri, 8 Mar 2024 11:33:08 -0500 Subject: [PATCH] fix(ssh): emulate pty on windows --- pkg/ssh/ssh.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/ssh/ssh.go b/pkg/ssh/ssh.go index 0a501a5a9..4cfde71c2 100644 --- a/pkg/ssh/ssh.go +++ b/pkg/ssh/ssh.go @@ -5,6 +5,7 @@ import ( "fmt" "net" "os" + "runtime" "strconv" "time" @@ -85,14 +86,19 @@ func NewSSHServer(ctx context.Context) (*SSHServer, error) { ), } - s.srv, err = wish.NewServer( + opts := []ssh.Option{ ssh.PublicKeyAuth(s.PublicKeyHandler), ssh.KeyboardInteractiveAuth(s.KeyboardInteractiveHandler), - ssh.AllocatePty(), wish.WithAddress(cfg.SSH.ListenAddr), wish.WithHostKeyPath(cfg.SSH.KeyPath), wish.WithMiddleware(mw...), - ) + } + if runtime.GOOS == "windows" { + opts = append(opts, ssh.EmulatePty()) + } else { + opts = append(opts, ssh.AllocatePty()) + } + s.srv, err = wish.NewServer(opts...) if err != nil { return nil, err }