fix(ssh): emulate pty on windows

Ayman Bagabas created

Change summary

pkg/ssh/ssh.go | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

Detailed changes

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
 	}