Created
May 16, 2020 21:58
-
-
Save fny/2ce2ebddd66c0b997cf71f036116d209 to your computer and use it in GitHub Desktop.
Ubuntu service to start an AutoSSH tunnel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=AutoSSH tunnel service | |
After=network-online.target sshd.service | |
[Service] | |
Environment="AUTOSSH_GATETIME=0" | |
Environment="AUTOSSH_PORT=0" | |
ExecStart=/usr/bin/autossh -o "ServerAliveInterval 10" -o "ServerAliveCountMax 3" -N -R 2222:localhost:22 -R 8888:localhost:8888 [email protected] | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mv autossh-tunnel.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable autossh-tunnel.service
systemctl start autossh-tunnel.service
Make sure you have SSH keys on every server set up as needed.
To allow binding to all ports
ssh -R *:8080:localhost:80 -N [email protected]
To allow binding to the server IPv4
ssh -R 0.0.0.0:8080:localhost:80 -N [email protected]
To allow binding to the server IPv6
ssh -R "[::]:8080:localhost:80" -N [email protected]