version 2026-02-12 sshd sshd | | sshd | +-------------+ \ | | + remote(for client 2001) | | remote(client 2000) + \ / \ + +------+ | \ | 8000\ |8000 central 8001/ |8001 +---+ + / \ / |6143 (port chosen by kernel) client client \2000 | \2001 +---+ | \ \ | \4321 (port chosen by kernel) ssh | ssh | ssh central always listens port 8001 1 - client starts, creates KEY, connects to central, sends KEY to central, waits for remote 2 - central opens port 8000, waits for remote 3 - remote connects to central on port 8000, sends KEY, if wrong key, central kills connection (remote AND client will need to restart) 4 - central creates a link between remote and client 6 - client/remote connected when ssh happens on client (kernel chooses port xx for ssh source port): 1 - client sends [ 0] to remote 2 - remote creates a tcp socket (let's call it RS) to 127.0.0.1 port 22 3 - all data from RS on remote is sent to client as [ ] and all data from client to remote is sent on RS socket, same format 4 - when remote socket RS dies remote sends [ -1] to client - when ssh on client is killed, client sends [ -1] to remote 5 - the end receiving [ -1] kills the ssh central link, deletes link when remote-central link dies, central kills client-central corresponding link and vice-versa messages: [ 0] : is an integer, 0 too [ -1] : is an integer, -1 too [ ]: and are integers, is a buffer of bytes, length of buffer: Integers are sent as 32 bits, little endian.