Log in to the remote server

$ ssh -NT [email protected]

Login with identity file(private key)

$ ssh -NT [email protected]

Local forwarding

Connect from the local port to another server through a middle server.

$ ssh -NTL local_port:127.0.0.1:target_port [email protected]

Local forwarding between 3 machines

Connect from the local port to another server through a middle server.

$ ssh -NTL local_port:target_server:target_port [email protected]

Remote forwarding

Let the local port can be connected through another server's port.

$ ssh -NTR remote_port:127.0.0.1:target_port [email protected]

Remote forwarding between 3 machines

Map the port of the remote server to a locally accessible address.

$ ssh -NTR remote_port:target_server:target_port [email protected]

Dynamic forwarding

It creates a socks proxy in a local port. Through this proxy, you can access all the content that the ssh server can access. e.g.: set socks5 proxy in browser with 127.0.0.1:port, then you can access any url that the ssh server can access.

$ ssh -NT [email protected]