ssh commands

posted on

i2p tunnel

creating a tunnel to a server running i2p

ssh -fTNL 4444:localhost:4444 -L 7070:localhost:7070 box
-fTN
run in the background, no tty allocation and no remote command, respectively
-L
local port forwarding, i.e. the requests to the local port (first number) on localhost (this machine) are forwarded to the remote port (second number) on my i2p box.
4444, 7070
the ports needed for i2p. 4444 is the proxy port and 7070 is the router console port
box
a placeholder for the name of the server

reverse tunnel

creating a reverse ssh tunnel from a firewalled host to a server

ssh -NT -o ServerAliveInterval=60 -R 11111:localhost:22 box
-NT
do not execute a remote command and do not allocate a tty
-o ServerAliveInterval=60
send a packet every 60 seconds to keep the connection alive – useful for long-lived connections
-R
reverse port forwarding, i.e. the requests to the remote port (first number) on the server are forwarded to the local port (second number) on the client
11111
the port on the server
localhost:22
the port on the client (ssh)
box
the 'outside' server

then, ssh -p 11111 user@localhost will connect to the firewalled host from the server.

jump hosts

if the server is used as a jump host, then ssh -J user@jumphost user@finalhost will connect to the final host through the jump host.

e.g. used with the previous command, ssh -J user@server -p 11111 user@localhost will connect to the firewalled host from the client via the server as the jump host.