Backspace, Tab not working in terminal (using ssh)

  • When I ssh into another machine with Debian with my account(with sudo permissions), my backspace key generates some awkward symbols on pressing. Also Tab & del keys don't work too.

    On the other hand, I also have another account on the same machine & when I ssh through this account, its terminal works perfectly fine. I couldn't figure out why is this happening.

  • Beside "stty" solution, you may try the "TERM" solution.

    You ssh to your Debian from some terminal (putty, solaris dterm, debain xterm, you-name-it), this termninal announce capabilities (which includes keys such as Backspace and Tab) via TERM environment variable.

    So, after ssh to unix host (it doesn't depend debian it or other host) set the TERM variable according to your terminal. Consider you're using bash as shell and vt100 as terminal:

    export TERM=vt100

    ps: TERM should be announced via ssh automagically, but in some circumstances this magic fails.

    still doesn't work :(

    What terminal are you using? And what the value of TERM you have tried?

    I tried vt100. How do I get to know the value of TERM? I tried ssh from cygwin (in windows) to Debian. If there are problems with cygwin, I even tried it from ubuntu terminal, but same problem.

    Not sure cygwin has good terminal emulation, as far as I know, cygwin just using regular windows console which lacks terminal emulation (may be wrong). From ubuntu all should works just fine. Something wrong with shell or termcap library on debian. Login from Ubuntu and give me output of commands: 1. echo $TERM 2. stty -a

    Well it works fine from my ubuntu machine, wonder why I hadn't verified it before.($TERM was 'xterm' there). So the problem is with cygwin only. Well anyways problem solved if it works with ubuntu :)

    While this didn't directly help me, since TERM was correctly set, it did help identify the problem. I was missing the terminfo entries for my terminal. I am using urxvt and on arch you need to install rxvt-unicode-terminfo to fix this particular issue

  • I have seen such problems before.

    Take the backspace for example, the remote host expects some character to be used as "erase/backspace" , while you pressing backspace in the terminal , the terminal program will send some character to the remote host, if what the remote host expects diffs with the characters sent by the terminal program, you would encounter this issue. So a quick fix is as below:

    1. run command #stty -a in the remote host, and find what is expected to be an erase code in the output. Say erase=^?.
    2. In the terminal, type Ctrlv and press your backspace. You'll see what code is sent as "erase". Say it is ^H.
    3. In the remote host, run #stty erase ^H.
      (Note: use Ctrlv + Backspace, do not type the ^ manually)

    You can fix the Tab issue with the same as above.

    My backspace character is some special symbol something like an inverted triangle. So its not working

    This simple comment is certainly the best solution I have seen to this. It feels like a kludge but it works.

    This worked for me! What I don't understand though is why my shell handles backspace as expected, but reading from stdin in my app does not. Doing your suggested change results in backspace working for both. My understanding is that the shell handles stdin buffering, so shouldn't the backspace-handling be the same for both the shell and an app?

    What if no code at all is sent? Ctrlv + backspace produces nothing...

    For me, the backspace code is the same as `stty -a` output, but still does not work

  • This is because your default shell is sh, to use bash, just run bash from your shell.


    To set bash as your default shell:

    chsh -s /bin/bash 


    sudo chsh -s /bin/bash yourusername

    This one fixed it for me. Never even though to look at my login shell!

    I am seeing this problem, but my shell is bash.

  • Your shell may be set to /bin/sh instead of /bin/bash

    This would be more helpful if it explained a little more and how to change it, but it was the problem I had. Thanks @Tom for your link that fixed the issue for me.

    This was the reason in my case.. for that particular user. No shell was defined in `/etc/passwd`, when I added `:/bin/bash` to his line it worked. You can find out what shell is being used with `echo $0`

  • I usually use this to fix any funky character output in my terminal. It resets all the special characters to their default values.

    stty sane

    From the stty man page:

    same as cread -ignbrk brkint -inlcr -igncr icrnl -iutf8 -ixoff -iuclc -ixany imaxbel 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, all special characters to their default values

  • on top of paul's answer, if you want to retain the ability to have colorful output, you can use xterm-88color

    echo 'export TERM=xterm-88color' >> ~/.bashrc
    source ~/.bashrc

    `toe -a` shows a list of supported terminal types ... `xterm-88color` is by far not the only option and in fact may be unavailable on particular systems.

  • Try this command

    stty sane

    I think your terminal line settings got corrupted, this command will reset everything to default.

    i had the same issue and this command solved it

  • After connecting from Fedora to an OpenWrt host with ssh the remote bash
    terminal had problems with some control characters. TERM variable in source
    host was set to rxvt-unicode-256color. Since it seemed that OpenWrt repos did
    not provide terminfo file for that terminal I copied rxvt-unicode-256color
    terminfo file from source host to remote host directory:
    /usr/share/terminfo/r/ .
    It worked.

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM