This is useful in cases where you are on another machine via SSH and want to forward a local listener that usually only listens on localhost (e.g. gcloud auth login).
ssh <-f> -N -L <local_port>:127.0.0.1:<remote_port> user@remote
Explanation:
-f→ background it (optional)-N→ don’t execute a remote command (just tunnel)-L→ local port forwardlocal_port→ port on your machine127.0.0.1:<remote_port>→ where SSH should connect on the remote side
Substitute the placeholders for the port of the listening service (e.g. 8085 for Google Oauth) and the hostname/IP of the machine that is listening on that port only in loopback. This will create an SSH tunnel from the port on your local machine to the normally loopbacked port listened on by the service.