Skip to content

Instantly share code, notes, and snippets.

@anikishov
Last active November 9, 2020 16:07
Show Gist options
  • Save anikishov/367cc58a4a62d2bea797ac0541cdc773 to your computer and use it in GitHub Desktop.
Save anikishov/367cc58a4a62d2bea797ac0541cdc773 to your computer and use it in GitHub Desktop.
Autossh systemd service config
Forward web-port (5000) and ssh (22).
systemctl daemon-reload
systemctl enable autossh.service
[Unit]
Description=Auto Reverse SSH
After=network.target auditd.service
[Service]
Type=simple
ExecStart=/usr/bin/autossh -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -N -p 22 -R 0.0.0.0:1122:127.0.0.1:22 -R 127.0.0.1:5000:127.0.0.1:5000 <autossh_server_hostname>
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
#####
# Need add following option in /etc/ssh/ssh_config
# autossh options
ExitOnForwardFailure yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment