[systemd-devel] lazy forwarding of ssh ports

Igor Bukanov igor at mir2.org
Mon Jan 28 13:40:28 PST 2013


I would like to forward-on-demand a local port to remote one over ssh.
Currently as a hack I use a socket unit with accept=yes together with
a service template unit that looks like:

[Service]
ExecStart=-/usr/bin/ssh options sever nc localhost port
StandardInput=socket

This works, but rather inefficient. The data is first copied to
systemd, that copies them to ssh, that forwards them to the nc command
running on the remote host that finally sends the data to the port.

It would be much better to use ssh -L port-forwarding option to avoid
all those extra data copies. Unfortunately ssh with its -L option does
not support inetd-style socket passing and always binds itself.

I suppose I can try to patch ssh to support that, but perhaps there is
some magic option in systemd that allows to redirect the accept
request to a new listening socket that ssh creates with its -L option?


More information about the systemd-devel mailing list