Linux - SSH - ssh console

SSH ESCAPE CHARACTERS
#####################

Note when I say Press ~ then it means you press the shift key followed by the button to the left of 1 key. Meaning Shift+` or just ~ which ever way you want to look at it

SSH SUPPORTED ESCAPE SEQUENCES:
  ~.  - terminate connection (and any multiplexed sessions)
  ~B  - send a BREAK to the remote system
  ~C  - open a command line
  ~R  - Request rekey (SSH protocol 2 only)
  ~^Z - suspend ssh
  ~#  - list forwarded connections
  ~&  - background ssh (when waiting for connections to terminate)
  ~?  - this message
  ~~  - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)


(3 Steps)

Our example here we have PC0 which has Windows and thus Putty installed on it, from it we will connect via SSH protocol on Putty to PC1 and we will use PC1 as the SSH client to connect to PC2 and PC3.

1. Make sure Putty or what ever client your using to have the shell window (ex: xterm, putty) allow for escape character Shift-` (which is Shift-~ or just ~ which ever way you want to look at it): In putty settings the default settings work - however if your like me you might change the default settings. Here is the setting we need - again this is setup by default:

Go to Terminal->Keyboard Category in Putty and select ESC[n~

NOTE: I usually have Xterm R6 as that allows me to have the extra F keys which is useful with program like "mc" where I get a full on file browser like midnight commander but to fully function it need all of the F keys 1 thru 12. The last few F keys dont work with ESC[n~ but they do work with Xterm R6

SOME OTHER USEFUL SETTINGS: Go to Category Window and Change Lines of scrollback from 200 to 2000000000 just tag on a few zeros, that way you can scroll with the shell screen all the way to the beginning

So now connect to PC1 from PC0, with PC0s Putty Program - making sure the Keyboard Settings are ESC[n~

2. This escape key is an ssh config not an sshd config. Meaning its a client side config not a server config. Example: If you use PC0 (windows with putty) to connect to PC1 (which is your ssh server and main client) and from PC1 you connect to PC2 or PC3. PC1 will be used like you client when you connect from PC1 to PC2 or PC1 to PC3.. (yah PC1 is your server when you connect from PC0 but thats besides the point)

Edit the settings on your main ssh client in the example above its PC1: /etc/ssh/ssh_config

Make sure the following line is not commented out:

EscapeChar ~

So if it looks like this # EscapeChar ~ then remove the ~

3. You might need to reload the ssh settings:

/etc/init.d/ssh reload

OR:

service ssh reload

Either way is equivalent.

4. Now connect from PC1 to any ssh server like PC2 or PC3 with the ssh command (Note the ssh_config on PC2 or PC3 doesnt need to have the EscapeChar directive, its only on the Client so PC1 that matters here) :

ssh user@PC2

or

ssh user@PC3

Now when you log in press the following:

Hold shift and press ` (which does the ~) then still holding shift press c. 
Inturn doing ~C
That gives you the ssh> console

Pressing Shift ` and then /
Shows you help for the Escape commands which I  show at the top, but here they are again:


SSH SUPPORTED ESCAPE SEQUENCES:
  ~.  - terminate connection (and any multiplexed sessions)
  ~B  - send a BREAK to the remote system
  ~C  - open a command line
  ~R  - Request rekey (SSH protocol 2 only)
  ~^Z - suspend ssh
  ~#  - list forwarded connections
  ~&  - background ssh (when waiting for connections to terminate)
  ~?  - this message
  ~~  - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)

With the ~C you can do remote and local and dynamic port forwards into the session you are in.

For example:
-----------
ssh user@PC2 -L 5050:localhost:40404

I could just 
ssh user@PC2

And then go to console with ~C

and then type -L 5050:localhost:40404

And you can tack several of them on
SelectionFile type iconFile nameDescriptionSizeRevisionTimeUser
Comments