I finally found an answer in Anne Baretta's Linux Keyboard Hall of Shame... it seems that changing key mappings in xterm
/ rxvt
does no good for telnet
.
I validated this when I sniffed the telnet connection. First I sniffed the telnet session and saw that Backspace sent 0x7f
to the host. Next I intentionally broke Backspace in rxvt
using stty erase $
(thus mapping my Backspace to the dollar sign in rxvt
). After doing this, I had to hit $ to backspace in rxvt
, but telnet
still sent 0x7f
when I used Backspace on the remote host.
SOLUTION
Create a script called kbdfix
(below), and make it executable with 755
permissions; you will need the tclsh
and expect
packages loaded from your distribution archives.
#!/usr/bin/expect
#Name this file as kbdfix and make it executable in your path
eval spawn -noecho $argv
interact {
\177 {send "\010"}
"\033\[3~" {send "\177"}
}
Now to connect to the broken hosts, I type kbdfix telnet 192.168.12.117 2006
, and Backspace works.
Note for anyone confused by 2006 above... that is the TCP port that the Cisco term server uses for the serial connection to the console of the broken device (in this case, a Brocade FCX switch).
If you are merely telnetting to a device that doesn't like Backspace, you would use kbdfix telnet <addr_of_the_broken_device>
. I am also using this with ssh when I ssh to a DLink DGS-3200 Ethernet switch that has similar issues; the syntax is kbdfix ssh 172.16.1.26
.
Create a user and set his login shell to your command.
For example:
sudo apt-get install sl
sudo adduser foo
sudo chsh -s $(which sl) foo
ssh foo@localhost
Also have a look at man sshd_config
for some other ways to configure you ssh server. (Like adding a ForceCommand
.)
Best Answer
Please have a look at the ttynvt driver [1]. It supports RFC2217, ioctls and tty line disciplines (tty and PPP).
[1] https://gitlab.com/lars-thrane-as/ttynvt