d54c6de0df5646d6ca258987145f9cd2728c3c33

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix(ssh): emulate pty on windows

Diff

 1diff --git a/pkg/ssh/ssh.go b/pkg/ssh/ssh.go
 2index 0a501a5a95e11a0b4f71c1408f15460a68c379fa..4cfde71c2bb712631198f50038c6a18db8c8f27c 100644
 3--- a/pkg/ssh/ssh.go
 4+++ b/pkg/ssh/ssh.go
 5@@ -5,6 +5,7 @@ import (
 6 	"fmt"
 7 	"net"
 8 	"os"
 9+	"runtime"
10 	"strconv"
11 	"time"
12 
13@@ -85,14 +86,19 @@ func NewSSHServer(ctx context.Context) (*SSHServer, error) {
14 		),
15 	}
16 
17-	s.srv, err = wish.NewServer(
18+	opts := []ssh.Option{
19 		ssh.PublicKeyAuth(s.PublicKeyHandler),
20 		ssh.KeyboardInteractiveAuth(s.KeyboardInteractiveHandler),
21-		ssh.AllocatePty(),
22 		wish.WithAddress(cfg.SSH.ListenAddr),
23 		wish.WithHostKeyPath(cfg.SSH.KeyPath),
24 		wish.WithMiddleware(mw...),
25-	)
26+	}
27+	if runtime.GOOS == "windows" {
28+		opts = append(opts, ssh.EmulatePty())
29+	} else {
30+		opts = append(opts, ssh.AllocatePty())
31+	}
32+	s.srv, err = wish.NewServer(opts...)
33 	if err != nil {
34 		return nil, err
35 	}