Skip to content

Instantly share code, notes, and snippets.

@YourFriendCaspian
Forked from jamiedust/bash-ssh-tunnelling
Created September 2, 2017 03:10
Show Gist options
  • Save YourFriendCaspian/335ea9bd2aa717b154f19fd3af99b8db to your computer and use it in GitHub Desktop.
Save YourFriendCaspian/335ea9bd2aa717b154f19fd3af99b8db to your computer and use it in GitHub Desktop.
Useful Bash/Linux SSH tunnelling commands
## Start SSH agent
eval "$(ssh-agent -s)"
## Open SSH tunnel on port 3307
ssh -fN -L 3307:127.0.0.1:3306 [email protected]
## Check the tunnel is active
sudo netstat -lnp | grep ssh | grep :3307
## Close the tunnel
ps aux | grep ssh | grep 3307 # get the pid
kill <pid> # kill process
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment