-
-
Save cellcoresystems/d805086ace127c4ec304f6b3b23d5f10 to your computer and use it in GitHub Desktop.
Systemd service for autossh
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=Keeps a tunnel to 'remote.example.com' open | |
After=network-online.target | |
[Service] | |
User=tunel | |
#ISTALLL | |
# sudo mv autossh.service /etc/systemd/system/ | |
# sudo systemctl enable autossh.service | |
# sudo apt install autossh | |
# sudo adduser --home /var/lib/tunel tunel | |
# sudo scp /var/lib/tunel/.ssh/id_rsa.pub [email protected]:/tmp/ | |
# ssh [email protected] -p 6969 'cat /tmp/id_rsa.pub >> /home/tunel/.ssh/authorized_keys' | |
# sudo su - tunel | |
# ssh -p 6969 [email protected] ls | |
# exit | |
# sudo systemctl start autossh.service | |
Environment=HOSTTUNEL=74.208.65.34 | |
Environment=USERTUNEL=tunel | |
Environment=PORTSERVER=6969 | |
Environment=REMOTE_PORT=2290 | |
Environment=LOCAL_PORT=22 | |
# -p [PORT] | |
# -lN Just open the connection and do nothing (not interactive) | |
# LOCALPORT:IP_ON_EXAMPLE_COM:PORT_ON_EXAMPLE_COM | |
ExecStart=/usr/bin/autossh -M 0 -N -q -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -p ${PORTSERVER} ${USERTUNEL}@${HOSTTUNEL} -R 0.0.0.0:${REMOTE_PORT}:localhost:${LOCAL_PORT} -i /var/lib/tunel/.ssh/id_rsa | |
[Install] | |
WantedBy=multi-user.targetsudo sudo systemctl enable autossh.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment