ssh reverse tunnel


На целевой машине,куда нужно попасть в итоге.
ssh -R local_port:localhost:remote_port user@remote_host -N -f -p ssh_port
или
autossh systemd_unit
/etc/systemd/system/tunnelhunt.service
[Unit]
Description=reverse SSH tunnel
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=your_user
#Environment=AUTOSSH_GATETIME=0
ExecStart=/usr/bin/autossh -M 0 -p -o BatchMode=yes -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -o ExitOnForwardFailure=yes -R local_port:localhost:remote_port remote_host
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target

В итоге заходим по ssh на и заходя на localhost: попадаем на машину с запущеным autossh.