Very often a database in production only accept connections from localhost, and we resort to use SSH tunneling to access it remotely. While tunnels are running in the background and we connect to the database on localhost, we need to know if we’re really talking to our localhost or to the remote machine.
example for connect remote elasticsearch server
ssh -C -f -N -g -L 9200:127.0.0.1:9200 user@ipaddressList all open SSH tunnels with:
sudo lsof -i -n | grep sshSome useful options to consider:
# -i shows the internet addresses
# -n does not resolve IP addressesRemove all tunnels
pgrep ssh | xargs kill