SSH crib

Port forwarding:

ssh -f -N -L user@host

-f requests ssh to go to background

-N do not execute a remote command, we just want to forward a port, nothing else

-L open local port and forward all traffic to specified remote address/port local port gonna be opened on loopback interface; can be replaced wirth just 127.1 ssh will forward all traffic to that address:port

Login using key:

ssh -i /path/to/key user@host

-i path to key file; file should be generated by `ssh-keygen` and copied to remote host using `ssh-copy-id` or manualy

Connection sharing - allows multiple 'virtual' ssh connections to operate via one real tcp session.

Master mode:

ssh -M -S /path/to/socket user@host

-M put ssh client to master mode

-S /path/to/socket master process will create that socket

Controlling existing connection:

ssh -S /path/to/socket -O exit

-O exit ask master process to exit; also some other commands available (such as 'check') - refer to man page

All together:

Start port forwarding session

ssh -f -N -L -i /path/to/key -M -S /path/to/socket user@host

Kill it:

ssh -S /path/to/socket -O exit user@host