1

I have following setup:

tunnel.service

[Unit]
Description=Setup a secure tunnel to %I
After=network.target

[Service]
ExecStart=/usr/bin/ssh -N -D 0.0.0.0:1080 myhost.name
User=snoopy


# Restart every >2 seconds to avoid StartLimitInterval failure
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target

And I want to start this service only when system have incoming connection to it!

I was read some docs about systemd socket activation, but it's like I can't open port using -D option of ssh

PS. Fedora 27 inside virtualbox

5n00py
  • 11
  • 1
  • To be clear, when sometimes connects to port 1080 on your machine, you want to start up an SSH tunnel, which then forwards the connection on to `myhost.name`? – Mark Stosberg May 17 '18 at 11:35
  • Yes! I have firefox addon that uses socks proxy for some urls. – 5n00py May 21 '18 at 20:02

1 Answers1

2

You may retrofit daemons without native support for socket-activation using systemd-socket-proxyd, as described in this SO reply specifically for SSH.

ankostis
  • 491
  • 5
  • 11