Tuesday, May 16, 2023

autossh

 Create /etc/systemd/system/autossh.service


[Unit]

Description=AutoSSH 

After=network.target


[Service]

Environment="AUTOSSH_GATETIME=0"

ExecStart=/usr/bin/autossh  -NR SOMEPORT:localhost:22 -i /home/pi/.ssh/id_rsa MYUSER@MYIP


[Install]

WantedBy=multi-user.target


source:

https://www.everythingcli.org/ssh-tunnelling-for-fun-and-profit-autossh/



OR

[Unit]

Description=Reverse SSH connection

After=network.target

[Service]

Type=simple

ExecStart=/usr/bin/ssh -vvv -g -N -T -o "ServerAliveInterval 10" -o "ExitOnForwardFailure yes" -i /home/pi/.ssh/id_rsa -R SOMEPORT:localhost:22 MYUSER@MYIP


Restart=always

RestartSec=5s


[Install]

WantedBy=default.target


No comments:

Post a Comment