views:

758

answers:

3

This has always bugged me. When I ssh or telnet to a Unix server (whatever flavour) it always manages to guess correctly the terminal type I am logging in from and so the keyboard always acts 'normally' ... i.e. the backspace key works.

But then when I have successfully logged in, it often guesses incorrectly the terminal type I am using and makes incorrect key mappings - especially for the backspace key, meaning I have to issue a:

stty erase ...

type command to fix it.

Any Unix gurus out there know why this happens?

+2  A: 

I think you mean backspace properly works when you are inputting your username and password, then it stops working after you've logged in.

Most likely stty is being set to something else in ~/.profile or /etc/profile (or another script that executes on login).

Find that file and comment the line.

rwired
Yes, sorry I should have been more explicit. This is more of a general question more than to a specific platform but you are right...it's probably as simple as something in the /etc/profile
gnuchu
A: 

What SSH/telnet software are you using?

When logging in via SSH, username/password entry is usually handled by the client, so it may be irrelevant.

My guess would be that the TERM environment variable is being set incorrectly by your terminal software, eg. set to "vt100" when terminal is set to behave like xterm, etc.

Hasturkun
+1  A: 

Secure shell (ssh) will most likely ask for the username and password in the client software before ever attempting to contact the host, so it's using local conventions.

Telnet will generally communicate with the telnetd daemon on the host (remote end) and the host will be handling I/O.

There's a good chance that your terminal program is configured correctly to talk to telnetd but, after logging in, a variety of scripts are run which can affect terminal settings (something like stty erase '^H'). Depending on the UNIX system you're connecting to and the shell you're using, this may be a combination of /etc/profile, ~/.profile, ~/.bashrc, ~/.kshrc and so on).

Your best bet is to find the last in the chain of profile-type files (probably ~/.profile) and put a stty erase 'X' in there, where X is the actual desired keystroke for your terminal program.

As an aside, the profile-type ones are run for a login shell only whilst the others tend to be run for any sub-shell created.

paxdiablo