Skip to content

Instantly share code, notes, and snippets.

@dgacitua
Created November 25, 2023 14:43
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 dgacitua/78961d04c24b442de9c595c4153f418e to your computer and use it in GitHub Desktop.
Save dgacitua/78961d04c24b442de9c595c4153f418e to your computer and use it in GitHub Desktop.
Bash script to deploy a SSH Tunnel from remote server to local machine
#!/bin/bash
# Customize the following variables
REMOTE_USERNAME=myuser # Remote server username
REMOTE_HOST=server.myuser.info # Remote server domain or IP address
REMOTE_PORT=4000 # Remote server port to redirect
LOCAL_PORT=3000 # Local machine port where the remote port is redirected
echo -e "Tunneling to $REMOTE_HOST from remote port $REMOTE_PORT to local port $LOCAL_PORT"
ssh $REMOTE_USERNAME@$REMOTE_HOST -p 22 -L $LOCAL_PORT:localhost:$REMOTE_PORT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment