In this tutorial, you will learn some SSH examples in practice

Local port forwarding

Why you need this?

In practice, you may like to forward a local port to get accessing to a cloud database or server residing in a private network behind a bastion/jump server

Bastion host is a computer specifically designed and configured to withstand attacks, generally hosts a proxy server providing access to a private network from an external network, such as the internet

How?

Type the following command on your terminal console

ssh -o ServerAliveInterval=5 -fNL LOCAL_PORT:REMOTE_HOST:REMOTE_PORT [email protected]_HOST

ServerAliveInterval is the number of seconds that the ssh client will wait before sending a message to request a response from server to keep the connection alive, value 0 means disabled (default)

-L LOCAL_PORT:REMOTE_HOST:REMOTE_PORT local port forwarding to remote host and port

-fN for running in the background

Generate public and private RSA key pair

ssh-keygen -C [email protected]