Skip to content

Instantly share code, notes, and snippets.

@nyrahul
Last active May 31, 2021 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nyrahul/767681eefc28a43e9d587bf61a7a9898 to your computer and use it in GitHub Desktop.
Save nyrahul/767681eefc28a43e9d587bf61a7a9898 to your computer and use it in GitHub Desktop.
ssh port forwarding
ssh -L 6060:127.0.0.1:6060 vagrant@192.168.34.11
golang pprof tool by default starts the pprof web server on localhost:6060. My pprof was running inside a VM and I needed to access the web server from the host. I could ssh to the VM. Thus I needed to enable port-forwarding on the host to the VM (remote).
ssh -L 6060:127.0.0.1:6060 vagrant@192.168.34.11
| | | |-------v------------|
| | | \--------------- remote ssh user@hostname
| | |
| | \--------- remote port to forward
| |
| \----------------- remote IP to forward ... in my case it was localhost
|
\------------------------ Local port to use for forwarding
After this I could use the web-browser on localhost:6060 __on the host__ to access the localhost:6060 on the VM.
[Update]
This even works with vagrant ssh.
vagrant ssh -- -L 6060:127.0.0.1:6060
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment