Why keys like Esc, Ctrl, Shift and Alt does not work in SSH session from my Windows PC?
I am working on Windows PC. If I open a terminal (with PuTTY or SSH) to a Linux (CentOS) machine, I can't get keys like Esc, Ctrl, Shift and Alt to work.
I need them for Midnight Commander (currently Ctrl+Ins and Shift+Ins are not working for me). Is it possible to get these keys to work?
Putty
emulates a terminal which is connected to the Unix
machine via serial (RS232c
) connection. Look here for configuration options. Typical terminal types include vt100
, vt200
, xterm
, ansi
.
To get proper operation, your Unix
environment variable TERM
has to match the type of terminal being emulated (cf. Putty
configuration Connection/Data/Terminal-type
). I am using xterm
, also for text-mode console windows.
Use echo $TERM
as command to find the current value.
Esc
is the first character of terminal control sequences. Therefore, it typically should not be used as stand-alone character. Ctrl, Shift and Alt on their own do not trigger any character to be sent to your Unix
machine. You can make use of the Putty
configuration menu Terminal/Keyboard
to influence how certain keys are translated.
Although PuTTY sets the TERM
variable to xterm
, its behavior does not in fact match xterm's behavior. There are two features mentioned in the question:
-
Escape as a prefix returned by special keys is provided by xterm as an alternative to the meta key (see the discussion of
eightBitInput
in the manual). - the other keys (Control, Shift and Alt) are typically used as *modifiers. That is, they usually do not send characters by themselves, but modify the behavior of a key pressed at the same time.
The ncurses FAQ How can I use shift- or control-modifiers? presents some of the background for modified keys. PuTTY does not implement any of that. It does modify the control sequences sent by a shifted cursor key, switching between normal and application modes (see the xterm FAQ Why can't I use the cursor keys in (whatever) shell? for some discussion of those terms).
ncurses has an accurate terminal description for the default configuration of PuTTY (several descriptions could be created to correspond to its keyboard dialog settings, but in practice those are rarely mentioned, probably rarely used). Systems with a complete terminal database will have that putty
terminal description.
Like other terminal emulators which set TERM
to xterm
, a complete terminal description has a lot of differences versus xterm
. The ncurses FAQ Why not just use TERM set to "xterm"? gives an overview to that aspect.
The mention of ssh hints that you may be using mintty
with Cygwin. That is a descendant of PuTTY
, with about the same limitations.