http://qs1969.pair.com?node_id=11122412


in reply to Re: Net::OpenSSH mater mode is not working
in thread Net::OpenSSH mater mode is not working

Ok , I will try to clear my goal.
If I append:

Host * controlmaster auto controlpath /tmp/ssh-%r@%h:%p

to ssh_config file,
Then I can: ssh host@ip:port to my server multiple times , and from the server side, I will only see only one active connection (the first one).
I would like to achieve samething using OpenSSH perl module.
What I can see is that openssh module creates random sockets , so it will never reuse an existing one (please add your opinion here)
like:

[root@smokeping probes]# ls -altr /tmp/.libnet-openssh-perl/ total 8 drwxrwxrwt. 12 root root 4096 Oct 1 10:02 .. srw-------. 1 root root 0 Oct 1 10:02 77920c754112ab47c6163bcfc58 +bed18 srw-------. 1 root root 0 Oct 1 10:02 0c600465ef924c5229c418a8871 +b9d36 srw-------. 1 root root 0 Oct 1 10:02 e675b23529a57eb7b59e85a7237 +7df74 srw-------. 1 root root 0 Oct 1 10:02 e4690abec752975a4476dd63232 +19814 srw-------. 1 root root 0 Oct 1 10:02 d3e28b44e996a2c3858850156cc +3b238 srw-------. 1 root root 0 Oct 1 10:02 24c7eb01f6b8e230db4e7ad7464 +6cc54 srw-------. 1 root root 0 Oct 1 10:02 8146e02629748a287f979c16827 +6b114 srw-------. 1 root root 0 Oct 1 10:02 6a7ebf7458398a282a947479de0 +14edc srw-------. 1 root root 0 Oct 1 10:02 6c1ebc546764c1bfbd755d1820d +bf5a5 srw-------. 1 root root 0 Oct 1 10:02 67d4449c8336035d4bc66fccf47 +ceddf srw-------. 1 root root 0 Oct 1 10:02 af933a70fa19f2e0631dd381587 +d9797 srw-------. 1 root root 0 Oct 1 10:02 09653a62f88e4954a6ba2c85a74 +37400 srw-------. 1 root root 0 Oct 1 10:02 b8b2ecc3c59c9bd14a147b0f4e4 +ebb01 srw-------. 1 root root 0 Oct 1 10:02 c9eb9ff5c25c1ea8bf8ae6fa0a9 +e6550 srw-------. 1 root root 0 Oct 1 10:02 966185842d9ab1ff5ce17afd3c9 +51893 srw-------. 1 root root 0 Oct 1 10:02 cf32ef2944cab6c8aeb5055b1a6 +72ee3 srw-------. 1 root root 0 Oct 1 10:02 a6c87213c639efca7be3d902b97 +f14ca srw-------. 1 root root 0 Oct 1 10:02 7c903101f2588c0d59ba1951806 +ab423 srw-------. 1 root root 0 Oct 1 10:02 0d8fe313c0fe25601df92bd10f5 +5f48a srw-------. 1 root root 0 Oct 1 10:02 5073e76ae24b05de392b4b12577 +7138e srw-------. 1 root root 0 Oct 1 10:02 a3c0acb9d2765801610a1c80c88 +e8086

So ... I dont know whow to tweak it to work as I want.
Should I force openssh module to create allways same socket and then add the propper rule to ssh_config system file ?
or both , perl module and ssh system client does nothing to do between them ?
Ok , hope to be more clear about my task.
Thanks.

Replies are listed 'Best First'.
Re^3: Net::OpenSSH mater mode is not working
by salva (Canon) on Oct 01, 2020 at 17:55 UTC
    Net::OpenSSH does not support the mode of operation where the master is reused if available or otherwise, a new one is created.

    The reason is that doing it in a reliable way is pretty hard, there are lots of race conditions and edge cases that should be handled. On the other hand it is something I had never found too useful.