Skip to content

Instantly share code, notes, and snippets.

@mbadley
Last active August 25, 2017 09:01
Show Gist options
  • Select an option

  • Save mbadley/3b552ca565c7dbea7ac3c7ac67f4be32 to your computer and use it in GitHub Desktop.

Select an option

Save mbadley/3b552ca565c7dbea7ac3c7ac67f4be32 to your computer and use it in GitHub Desktop.
ssh tunnel
#/bin/bash
# examples of ssh tunnels
# example 1
# ssh -f user@personal-server.com -L 2000:personal-server.com:25 -N
# The -f tells ssh to go into the background just before it executes the command.
# This is followed by the username and server you are logging into.
# The -L 2000:personal-server.com:25 is in the form of -L local-port:host:remote-port.
# Finally the -N instructs OpenSSH to not execute a command on the remote system.
# This forwards the local port 2000 to port 25 on personal-server.com over with the benefit of being encrypted.
# I then point my E-mail client to use localhost:2000 as the SMTP.
# example 2
# ssh -f -L 3000:talk.google.com:5222 home -N
# home is alias of laptop (could be any local server name)
# example 3 Bypass NAT
# ssh abc@def -R 8080:127.0.0.1:80
# GatewayPorts yes in sshd config file
# abc - username
# def - server address
# 8080 - port number that will be opened on remote server - our proxy server
# 127.0.0.1 - IP address we open tunnel to
# 80 - port number we open tunnel to
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment