1

When opening an SSH console on an already established connection (e.g. LF ~ C), I get ^H instead of backspace regardless of terminal and setup (that I've tried).

It is really bad as any mistake requires ^C which then breaks the connection.

Is there a sure way to have backspace work?

terminal is xterm

XTERM_VERSION=XTerm(402)
XTERM_SHELL=/bin/bash
XTERM_LOCALE=C
TERM=xterm

(tried TERM=xterm-direct, and TERM=st, which fixes somes wayland issues)

$ stty -a
speed 38400 baud; rows 30; columns 128; line = 0;
intr = ^C; quit = ^\; erase = ^H; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S;
susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb parodd -cmspar cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc
10
  • So what have you tried? Commented Sep 24 at 0:18
  • 1
    What's the output of stty -a (inside and outside ssh session) and in particular the erase setting? Terminals sending ^H instead of ^? upon Backspace is unusual there days. Which are you using? Commented Sep 24 at 4:18
  • 2
    ^C from the ssh console doesn't break the connection for me on Ubuntu. Only exits the ssh console. What OS are you using and which implementation and version of the ssh client? How do you start it? Commented Sep 24 at 4:26
  • 3
    @terdon in newer versions of the openssh client, commandline is disabled by default. You'd need to reenable it in your ~/.ssh/config (look for EnableEscapeCommandline in man 5 ssh_config) Commented Sep 24 at 9:40
  • 2
    Please add the requested information to your question, not in comment. Commented Sep 29 at 14:16

1 Answer 1

3

This has nothing to do with ssh and everything to do with your terminal emulator and termios on the remote server. (ssh is just between them.)

The problem is that some terminals produce ^? for backspace and some produce ^H and some let you change the default. You can check the settings in your terminal emulator for this.

Similarly, the tty on the server can have its backspace character changed, and there is not really a (single) standard default. You can change it with the stty command. Since you know your terminal is producing ^H, you could change it with stty erase ^h or if you are uncertain what the key is, you can type stty erase and then CtrlV and then press your chosen backspace key and hit return.

It doesn't matter if you change this on the server side or change this in your terminal settings, just make them agree.

Note that shells that implement their own command line editing (like tcsh, bash, zsh, others), they probably accept both keys, but other programs that use standard tty cooked mode will not.

3
  • Thanks. stty erase <^H> on the local client (remote server still ^?) made backspace work there. Still unsure what i'm aiming for in being compatible with what exactly. edit: and even more confusing why having it to ^? generates a ^H string instead of deleting the char :) Commented Sep 29 at 14:11
  • I was almost sure it was a terminal issue, hence the terminal tag being the first one. Just don't know how to describe something i don't know the name, so i used ssh as the best example. Commented Sep 29 at 14:14
  • 1
    @gcb, you've still not said what terminal or terminal emulator application you were using. Maybe it can be reconfigured to send ^? instead of ^H upon backspace. Commented Sep 29 at 14:16

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.