Skip to content

Instantly share code, notes, and snippets.

@DoZator
Last active May 22, 2023 07:02
Show Gist options
  • Save DoZator/861a30535512f102596aea412d5e8fe7 to your computer and use it in GitHub Desktop.
Save DoZator/861a30535512f102596aea412d5e8fe7 to your computer and use it in GitHub Desktop.
SSH Tunneling (SSH port forwarding)

Opening SSH tunnel in a shell

    ssh -L 3000:localhost:3000 -N remotehost

-N - for "run no command". To create a local port forwarding, pass the -L option to the ssh client

    ssh -L 3000:localhost:3000 -N remotehost &

& - for send that SSH process to the background

MongoDB port forwarding as example:

$ ssh -N -L 27017:127.0.0.1:27017 remotehost &

Close: find process with ps command then kill

    kill $!

or

    kill %1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment