Skip to content

Instantly share code, notes, and snippets.

@Belval
Last active April 5, 2021 11:34
Show Gist options
  • Save Belval/48d2d7222466c524f3b1f9e83ab19e48 to your computer and use it in GitHub Desktop.
Save Belval/48d2d7222466c524f3b1f9e83ab19e48 to your computer and use it in GitHub Desktop.
A script to setup ssh tunnelling with autossh on a client
# First run setup_autossh_server.sh on your server THEN run this one
# Install autossh
sudo apt install autossh
# Create user tunnel
sudo useradd -m tunnel
sudo su tunnel
# Create key pair
ssh-keygen
# Copy it to the server
ssh-copy-id -i tunnel@[YOU IP/DOMAIN HERE]
autossh -nNT -L [PORT]:localhost:[PORT] tunnel@[YOU IP/DOMAIN HERE]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment