I’m constantly having trouble with getting the backspace and delete keys to work properly in OS X. Whenever it works right on the Mac, one or the other key is broken when I Â SSH to a Linux or FreeBSD box.

After some searching, I’ve found this solution, which seems to be working:

  1. First, got to the Terminal menu, and choose Preferences… Under the Settings section, choose the Advanced tab. Make sure Delete sends Ctrl-H is checked.
  2. Then, in the same window, go to the Keyboard tab (right next to Advanced). Find the line for forward delete, and set it to this value:
    \033[3~
  3. Lastly, you need to run the following line at the terminal. The trick with the line below though is that you need to type the ^H by pressing Control-V and then Control-H. You can not just cut and paste the line below, you need to type it:
    echo -e "stty erase ˆH" >> ~/.bash_profile
    Now you can restart Terminal, and your backspace and delete should work correctly everywhere!

For further reading on this topic check out these two links:

This problem, and various solutions are documented all over the net, but I found and used this page most recently.