Skip to content

Instantly share code, notes, and snippets.

@bukowa
Created February 14, 2025 19:06
Show Gist options
  • Save bukowa/8d8bfa68dfda2f3b748db5ea79cca265 to your computer and use it in GitHub Desktop.
Save bukowa/8d8bfa68dfda2f3b748db5ea79cca265 to your computer and use it in GitHub Desktop.
sshd reverse tunnel proxy
# pc
[Unit]
Description=AutoSSH tunnel for PC1 to EC2
After=network.target
[Service]
User=buk
ExecStart=/usr/bin/autossh -i /home/buk/.ssh/ec2.pem -M 0 -N -R 2222:localhost:22 ec2-user@<ip> -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -o ExitOnForwardFailure=yes
Restart=always
RestartSec=1min
[Install]
WantedBy=multi-user.target
# ec2
AllowTcpForwarding yes
GatewayPorts yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment