I had difficulties getting ssh(1)'s ESCAPE CHARACTERS to be recognized
from within a login shell over ssh. In particular, sometimes the escape
character was not recognized as such. I was able to find in gmane a
similar issue for a Gentoo user from a few years ago. I don't have
that gmane URL handy.
Do you find the below patch acceptable?
--- a/usr/share/man/man1/ssh.1.gz 2012-04-19 21:47:00.933890166 +0300
+++ b/usr/share/man/man1/ssh.1 2012-04-19 17:20:24.000000000 +0300
@@ -866,6 +866,11 @@ A single tilde character can be sent as
or by following the tilde by a character other than those described below.
The escape character must always follow a newline to be interpreted as
special.
+With a login shell, one might issue a single new line character to prepare
+the correct conditions for ssh to catch the escape character.
+If the escape character is cought by the remote application, perhaps
+it is echoed back by a login shell, then it will not affect the
+underline ssh channel.
The escape character can be changed in configuration files using the
.Cm EscapeChar
configuration directive or on the command line by the
@@ -913,6 +918,8 @@ option is enabled in
Basic help is available, using the
.Fl h
option.
+Pressing the return key twice will close the command line after it
+was started from a login shell.
.It Cm ~R
Request rekeying of the connection
(only useful for SSH protocol version 2 and if the peer supports it).