- Can /usr/bin/ssh really not accept systemd-passed sockets?
Acho que isso não é muito surpreendente, considerando:
- OpenSSH é um projeto do OpenBSD
- o systemd suporta apenas o kernel do Linux O suporte ao
- systemd precisaria ser adicionado explicitamente ao OpenSSH, como uma dependência opcional / de tempo de construção, portanto, provavelmente seria uma tarefa difícil.
- Can only units of root use the
BindTodeviceoption?
As instâncias do systemd do usuário geralmente são bastante isoladas e, por exemplo, não pode se comunicar com a instância principal pid-0. Coisas como dependendo das unidades do sistema a partir dos arquivos da unidade do usuário não são possíveis.
A documentação para BindToDevice menciona:
Note that setting this parameter might result in additional dependencies to be added to the unit (see above).
Devido à restrição mencionada acima, podemos sugerir que a opção não funciona nas instâncias do sistema do usuário.
- Why is my proxy service not respawning correctly on first new connection after the old tunnel dies?
Pelo que entendi, a cadeia de eventos é a seguinte:
-
SocksProxyHelper.socketé iniciado. - Um cliente SOCKS se conecta ao localhost: 8118.
- o systemd inicia
SocksProxyHelper.service. - Como uma dependência de
SocksProxyHelper.service, o systemd também iniciaSocksProxy.service. -
systemd-socket-proxydaceita o soquete systemd e encaminha seus dados parassh. -
sshmorre ou é morto. - avisos do systemd e coloca
SocksProxy.serviceem um estado inativo, mas não faz nada. -
SocksProxyHelper.servicecontinua em execução e aceitando conexões, mas não consegue se conectar assh, pois não está mais em execução.
A correção é adicionar BindsTo=SocksProxy.service a SocksProxyHelper.service . Citando sua documentação (ênfase adicionada):
Configures requirement dependencies, very similar in style to
Requires=. However, this dependency type is stronger: in addition to the effect ofRequires=it declares that if the unit bound to is stopped, this unit will be stopped too. This means a unit bound to another unit that suddenly enters inactive state will be stopped too. Units can suddenly, unexpectedly enter inactive state for different reasons: the main process of a service unit might terminate on its own choice, the backing device of a device unit might be unplugged or the mount point of a mount unit might be unmounted without involvement of the system and service manager.When used in conjunction with
After=on the same unit the behaviour ofBindsTo=is even stronger. In this case, the unit bound to strictly has to be in active state for this unit to also be in active state. This not only means a unit bound to another unit that suddenly enters inactive state, but also one that is bound to another unit that gets skipped due to a failed condition check (such asConditionPathExists=,ConditionPathIsSymbolicLink=, … — see below) will be stopped, should it be running. Hence, in many cases it is best to combineBindsTo=withAfter=.
- Is this the right way to set-up an "on-demand ssh socks proxy"? If, not, how do you do it?
Provavelmente não há "caminho certo". Este método tem suas vantagens (tudo sendo "on-demand") e desvantagens (dependência do systemd, a primeira conexão não sendo obtida porque o ssh não começou a escutar ainda). Talvez a implementação do suporte à ativação do soquete systemd no autossh seja uma solução melhor.