From 0fc45944bd36c7c0f29027206ecc41d557a219fe Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Tue, 1 Jul 2025 19:26:33 +0000 Subject: [PATCH] Fix SSH terminal modes for better MobaXTerm compatibility This change configures proper terminal control character mappings in the SSH PTY request to improve compatibility with SSH clients like MobaXTerm. Previously, an empty TerminalModes{} was used, which could cause control sequences like Ctrl+R (reverse search) to not work properly in certain clients. The fix includes standard terminal control characters such as: - VINTR (Ctrl+C), VQUIT (Ctrl+\), VERASE (Backspace) - VKILL (Ctrl+U), VEOF (Ctrl+D), VSUSP (Ctrl+Z) - VREPRINT (Ctrl+R), VWERASE (Ctrl+W), VLNEXT (Ctrl+V) - VSTART (Ctrl+Q), VSTOP (Ctrl+S), VDISCARD (Ctrl+O) This should resolve issues where MobaXTerm users experience problems with command history search and other terminal control sequences. Co-authored-by: sreya <4856196+sreya@users.noreply.github.com> --- cli/ssh.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/cli/ssh.go b/cli/ssh.go index 56ab0b2a0d3af..d218fb1457335 100644 --- a/cli/ssh.go +++ b/cli/ssh.go @@ -557,7 +557,28 @@ func (r *RootCmd) ssh() *serpent.Command { } } - err = sshSession.RequestPty("xterm-256color", 128, 128, gossh.TerminalModes{}) + // Configure terminal modes for better compatibility with SSH clients like MobaXTerm. + // This ensures that control sequences like Ctrl+R (reverse search) work properly. + terminalModes := gossh.TerminalModes{ + gossh.ECHO: 1, // Enable echo + gossh.TTY_OP_ISPEED: 14400, // Input speed = 14.4kbaud + gossh.TTY_OP_OSPEED: 14400, // Output speed = 14.4kbaud + gossh.VINTR: 3, // Ctrl+C (interrupt) + gossh.VQUIT: 28, // Ctrl+\ (quit) + gossh.VERASE: 127, // Backspace + gossh.VKILL: 21, // Ctrl+U (kill line) + gossh.VEOF: 4, // Ctrl+D (end of file) + gossh.VEOL: 0, // End of line + gossh.VEOL2: 0, // End of line 2 + gossh.VSTART: 17, // Ctrl+Q (start) + gossh.VSTOP: 19, // Ctrl+S (stop) + gossh.VSUSP: 26, // Ctrl+Z (suspend) + gossh.VREPRINT: 18, // Ctrl+R (reprint line) + gossh.VWERASE: 23, // Ctrl+W (word erase) + gossh.VLNEXT: 22, // Ctrl+V (literal next) + gossh.VDISCARD: 15, // Ctrl+O (discard output) + } + err = sshSession.RequestPty("xterm-256color", 128, 128, terminalModes) if err != nil { return xerrors.Errorf("request pty: %w", err) }