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.
List all open SSH tunnels with:
sudo lsof -i -n | grep ssh
Some useful options to consider:
# -i shows the internet addresses
# -n does not resolve IP addresses
one useful command is
watch "ps aux | grep ssh | grep -Eo '^[^ ]+' | sort | uniq"
to see who is online.