Skip to main content

SSH

SSH stands for secure shell.

SSH Tunnel

This is the session set up between the SSH client and server processes. It happens after authentication. It's the default SSH setup. Nothing special. The tunnel holds many channels for different kinds of data.

ssh-tunnel

Standard IO in SSH

The SSH client takes all stdin from the user. It encrypts it and sends it through the ssh tunnel.

The SSH server gets the data over the tunnel. It decrypts it and forks a new process to run the command. The command's stdout is written to the server's stdin. That's then sent to the client's session.

When the client gets the response, it routes it to the stdout stream of the client process.

See SSH similar to HTTP

Just see that SSH is no different from HTTP. It's an application layer protocol with its own rules for client and server.

SSH Channels

Like HTTP2, SSH uses many channels over the same TCP session.

One main channel carries stdin and stdout. Another carries stderr. Many more cover other needs.

Channels are at application layer

SSH channels are implemented at application layer.

The packets carry a special header. The client uses it to tell the data streams apart.

TCP Session

When an SSH connection is set up, the same TCP session lasts between the client and server. It ends when you close it by hand, or when it's idle for a long time.

Terminal-shell connection

How terminals on local machine are connected to bash on the remote machine can be read in the terminals doc.