Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Fix backspace/delete when ssh'ing into Linux machines UNIX
I have experienced the same problem in a range of applications: when I SSH from my Macs into Linux machines, the backspace key often stops working. I wasn't content to keep checking and un-checking the 'delete sends backspace' option, because these things ought to be automatic. I traced the problem to the Linux (Debian, at least) default terminfo entry for xterm-color. Terminfo is a database present on most Unix systems that tells programs how to interact with a variety of different terminals.

The solution: Copy the xterm-color terminfo file from a Mac to the Linux box. If you have Fink installed, get the file from /sw -> share -> terminfo -> x -> xterm-color; otherwise, use the one installed by default at /usr -> share -> terminfo -> 78 -> xterm-color. You can put the file in /usr -> share -> terminfo -> x/ on the Linux box (if you have root access), or in your home directory in ~/.terminfo -> x/ (create the directory structure if necessary). Then log out and SSH back into the Linux machine, and your backspace key should work properly in all applications.

This fixes zsh and screen for me, and keeps emacs working properly both on OS X and when SSH'd into a Linux machine.
  • Currently 3.50 / 5
  You rated: 1 / 5 (10 votes cast)

Fix backspace/delete when ssh'ing into Linux machines | 13 comments | Create New Account
Click here to return to the 'Fix backspace/delete when ssh'ing into Linux machines' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
There is another way
Authored by: atverd on Oct 05, '04 12:59:36PM

This is a very common and very annoying problem. Your remote host expects some character to be used as "erase", a terminal program you use sending some character as "erase". If they differ - sometimes you getting ^? or ^H when pressing backspace. So to fix this you just need bring both parts in sync.
1. When connected type "stty -a" and in output find what is expected to be an erase code (erase = ^? f.e.)
2. Type CTRL-v and press your backspace. You'll see what code is sent as "erase". ^H f.e.
3. Type "stty erase ^H" and this is it. Now they'll understand each other.

[ Reply to This | # ]
There is another way
Authored by: cougar718 on Oct 05, '04 02:12:36PM

That explanation should be the tip. I have been lookin' for a solution to that problem for a long time. Thanks man!

Rick alias cougar

[ Reply to This | # ]
There is another way
Authored by: guybrush on Oct 05, '04 02:25:26PM

actually already a hint, i remember using the hint myself in my .bash_profile:

[ Reply to This | # ]
There is another way
Authored by: jeremyp on Oct 05, '04 02:23:16PM

There's an easier way.

Just log in to the machine and type "stty erase " (note the space after "erase") and then hit the backspace key. Either the last space will get erased (backspace functioning correctly, delete the rest of the line) or the correct control character will appear on the screen and you can just press return then.

[ Reply to This | # ]
There is another way
Authored by: dthorburn on Oct 05, '04 08:05:16PM
The way I handle this is to have a pair of shell aliases set up for the stty erase entry. in your ~/.tcshrc:

alias ^H 'stty erase ^H'
alias ^? 'stty errase ^?'
or in ~/.bashrc

alias ^H='stty erase ^H'
alias ^?='stty errase ^?'
That way, whenever the backspace key is confused you can type backspace as a command and it will fix itself.

[ Reply to This | # ]
OS X / Debian / pico
Authored by: qryss on Oct 05, '04 07:01:48PM

I have a problem that is slightly different.

Using Terminal, I can log into Debian Linux machines fine - and the delete key works as expected at the command line (so the "stty erase " trick erases the space) - but when I use pico the delete key becomes a "forward delete" key.

Any clues how I fix that..?

This behaviour does not happen when I log in with (shudder) Putty from a (shudder) Windows machine.

[ Reply to This | # ]
OS X / Debian / pico
Authored by: cclark on Oct 05, '04 08:46:07PM

I have the same issue when logging into a RH 7.2 box from my PB. Everything works fine in the terminal but the minute I start vim my backspace is interpreted as a delete and erases the character the cursor is on. I am still not sure how to fix it...

[ Reply to This | # ]
OS X / Debian / pico
Authored by: eDogg on Oct 06, '04 09:08:19AM
I struggled with this a while back myself. Instead of posting the fix here, check the article on my blog. I hope this helps someone else too :-)

[ Reply to This | # ]
OS X / Debian / pico
Authored by: brasscannon on Jan 04, '05 11:58:56AM
Easy fix: Terminal, Preferences menu, "Declare terminal type ($TERM) as: [vt102]" instead of [xterm-color].

Log back in, or at least do "export TERM=vt102" on the Linux end.

Verify that keyboard "delete" is ^? and deletes to left of the cursor; keypad "delete" is ^[[3~ and deletes to the right of the cursor.

("Ctrl-V and press key" to see what it's sending is a good trick to know! Thanks for the reminder.)

Works perfectly in Debian's pico-lookalike, nano.

[ Reply to This | # ]

Fix backspace/delete when ssh'ing into Linux machines
Authored by: kholburn on Oct 05, '04 09:40:13PM

I ssh to debian systems all the time. The simplest thing I have found is to open the terminal inspector for your window, use the menu to select "keyboard" and tick or untick the checkbox labelled "Delete key sends backspace"

[ Reply to This | # ]
Fix backspace/delete when ssh'ing into Linux machines
Authored by: shredda on Oct 12, '04 03:24:21AM

Then just try to start 'screen' and use your backspace key. See what i mean?

[ Reply to This | # ]
Easiest solution
Authored by: adambyrtek on Nov 08, '06 08:58:28AM

Your solution is not too convenient as it requires copying files to every server I use. I found much simpler solution:

Just set "Declare terminal type" in Terminal Preferences to "rxvt".

This solved the problem for me. Regards,

[ Reply to This | # ]
Fix backspace/delete when ssh'ing into Linux machines
Authored by: zaclondon on Mar 11, '10 03:26:57AM

Thanks for the tips, although I couldn't get them to work for me.

I came across a much simpler solution.

Go to Terminal preferences, select the Advanced tab and tick 'Delete sends Ctrl-H'. And that's it! Backspace should work as usual in ssh/screen.

[ Reply to This | # ]