How to exit OpenSSH control master process without using lsof or fuser?How to close (kill) ssh ControlMaster...

What is this welding tool I found in my attic?

wavelength of seismic wave with a gaussian source

QGIS Linestring rendering curves between vertex

Why did the Japanese attack the Aleutians at the same time as Midway?

Is killing off one of my queer characters homophobic?

Construct a pentagon avoiding compass use

How to remove " 's" in a string?

As a DM, how to avoid unconscious metagaming when dealing with a high AC character?

Can I play a first turn Simic Growth Chamber to have 3 mana available in the second turn?

Mistakenly modified `/bin/sh'

Why hasn't the U.S. government paid war reparations to any country it attacked?

How to repair a laptop's screen hinges?

Is this floating-point optimization allowed?

The monorail explodes before I can get on it

What is the English equivalent of 干物女 (dried fish woman)?

Pre-1968 YA science fiction novel: robot with black-and-white vision, later the robot could see in color

Does Google Maps take into account hills/inclines for route times?

Doing research in academia and not liking competition

Players of unusual orchestral instruments

download the bitcoin chain begining from a certain date

To accent or not to accent in Greek

How do Windows version numbers work?

Do native speakers use ZVE or CPU?

Too many spies!



How to exit OpenSSH control master process without using lsof or fuser?


How to close (kill) ssh ControlMaster connections manuallyWork around two-factor SSH auth with Master connection and port forwarding?Using autossh to create a persistent, multiplexed ssh connection without any port forwarding?SSH/SCP Connection problem | Lost connectionHow to chain ssh commands over multiple hops?SSH Configuration Help / Can't tunnelJumphost suddenly reseting first SSH MUX connection attemptsPlease explain this SSH connection command formatHow to cleanup SSH reverse tunnel socket after connection closed?passwordless ssh to localhost in Ubuntu 16.04OpenSSH's SSH client not respecting order of IdentityFile settings






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







5















Is there a more direct way to exit an OpenSSH control master process and delete its socket file than with the help of the programs lsof or fuser and without knowing the destination host (connection details) as suggested by the accepted answer of this question? I thought of something like this along the lines of:



$ ssh -O exit -S ~/.ssh/7eb92b0827f3e8e1e8591fb3d1a5cd1b94b758cb.socket


I'm asking because I'm looking for a scriptable way to exit every open control master connection each time when I log out of my user account. Not doing so causes my sytemd-powered openSUSE computer to wait for a timeout of two minutes until it forcefully terminates the still open control master connection powering off eventually.



Unfortunately OpenSSH's client program ssh requires the destination host and the ControlPath file name pattern in order to deduce the actual file path to the socket file. I on the contrary thought of the more direct method of providing the concrete socket file via the program's -S ctl_path option.



In the global section of my system-wide OpenSSH client config file I configured OpenSSH's connection multiplexing feature as follows:



ControlMaster auto      
ControlPath ~/.ssh/%C.socket
ControlPersist 30m


Please note that I want to keep the file name pattern for socket files, i.e. hashing the token string %l%h%p%r with the token %C.



Any ideas?










share|improve this question

























  • @slm: I was already aware of the answer unix.stackexchange.com/questions/24005/… but it doesn't suffice my needs. I therefore chose a very specific title for this question. Basically how to accomplish closing an OpenSSH control master connection without lsof or fuser. Maybe I should have further restricted it to without knowing the destination host (connection details).

    – Tim Friske
    Jul 30 '18 at 20:49











  • I think I figured out the issue, see A'er.

    – slm
    Jul 30 '18 at 23:21


















5















Is there a more direct way to exit an OpenSSH control master process and delete its socket file than with the help of the programs lsof or fuser and without knowing the destination host (connection details) as suggested by the accepted answer of this question? I thought of something like this along the lines of:



$ ssh -O exit -S ~/.ssh/7eb92b0827f3e8e1e8591fb3d1a5cd1b94b758cb.socket


I'm asking because I'm looking for a scriptable way to exit every open control master connection each time when I log out of my user account. Not doing so causes my sytemd-powered openSUSE computer to wait for a timeout of two minutes until it forcefully terminates the still open control master connection powering off eventually.



Unfortunately OpenSSH's client program ssh requires the destination host and the ControlPath file name pattern in order to deduce the actual file path to the socket file. I on the contrary thought of the more direct method of providing the concrete socket file via the program's -S ctl_path option.



In the global section of my system-wide OpenSSH client config file I configured OpenSSH's connection multiplexing feature as follows:



ControlMaster auto      
ControlPath ~/.ssh/%C.socket
ControlPersist 30m


Please note that I want to keep the file name pattern for socket files, i.e. hashing the token string %l%h%p%r with the token %C.



Any ideas?










share|improve this question

























  • @slm: I was already aware of the answer unix.stackexchange.com/questions/24005/… but it doesn't suffice my needs. I therefore chose a very specific title for this question. Basically how to accomplish closing an OpenSSH control master connection without lsof or fuser. Maybe I should have further restricted it to without knowing the destination host (connection details).

    – Tim Friske
    Jul 30 '18 at 20:49











  • I think I figured out the issue, see A'er.

    – slm
    Jul 30 '18 at 23:21














5












5








5


2






Is there a more direct way to exit an OpenSSH control master process and delete its socket file than with the help of the programs lsof or fuser and without knowing the destination host (connection details) as suggested by the accepted answer of this question? I thought of something like this along the lines of:



$ ssh -O exit -S ~/.ssh/7eb92b0827f3e8e1e8591fb3d1a5cd1b94b758cb.socket


I'm asking because I'm looking for a scriptable way to exit every open control master connection each time when I log out of my user account. Not doing so causes my sytemd-powered openSUSE computer to wait for a timeout of two minutes until it forcefully terminates the still open control master connection powering off eventually.



Unfortunately OpenSSH's client program ssh requires the destination host and the ControlPath file name pattern in order to deduce the actual file path to the socket file. I on the contrary thought of the more direct method of providing the concrete socket file via the program's -S ctl_path option.



In the global section of my system-wide OpenSSH client config file I configured OpenSSH's connection multiplexing feature as follows:



ControlMaster auto      
ControlPath ~/.ssh/%C.socket
ControlPersist 30m


Please note that I want to keep the file name pattern for socket files, i.e. hashing the token string %l%h%p%r with the token %C.



Any ideas?










share|improve this question
















Is there a more direct way to exit an OpenSSH control master process and delete its socket file than with the help of the programs lsof or fuser and without knowing the destination host (connection details) as suggested by the accepted answer of this question? I thought of something like this along the lines of:



$ ssh -O exit -S ~/.ssh/7eb92b0827f3e8e1e8591fb3d1a5cd1b94b758cb.socket


I'm asking because I'm looking for a scriptable way to exit every open control master connection each time when I log out of my user account. Not doing so causes my sytemd-powered openSUSE computer to wait for a timeout of two minutes until it forcefully terminates the still open control master connection powering off eventually.



Unfortunately OpenSSH's client program ssh requires the destination host and the ControlPath file name pattern in order to deduce the actual file path to the socket file. I on the contrary thought of the more direct method of providing the concrete socket file via the program's -S ctl_path option.



In the global section of my system-wide OpenSSH client config file I configured OpenSSH's connection multiplexing feature as follows:



ControlMaster auto      
ControlPath ~/.ssh/%C.socket
ControlPersist 30m


Please note that I want to keep the file name pattern for socket files, i.e. hashing the token string %l%h%p%r with the token %C.



Any ideas?







ssh openssh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 1 '18 at 21:08







Tim Friske

















asked Jul 30 '18 at 20:42









Tim FriskeTim Friske

1,0801 gold badge12 silver badges23 bronze badges




1,0801 gold badge12 silver badges23 bronze badges













  • @slm: I was already aware of the answer unix.stackexchange.com/questions/24005/… but it doesn't suffice my needs. I therefore chose a very specific title for this question. Basically how to accomplish closing an OpenSSH control master connection without lsof or fuser. Maybe I should have further restricted it to without knowing the destination host (connection details).

    – Tim Friske
    Jul 30 '18 at 20:49











  • I think I figured out the issue, see A'er.

    – slm
    Jul 30 '18 at 23:21



















  • @slm: I was already aware of the answer unix.stackexchange.com/questions/24005/… but it doesn't suffice my needs. I therefore chose a very specific title for this question. Basically how to accomplish closing an OpenSSH control master connection without lsof or fuser. Maybe I should have further restricted it to without knowing the destination host (connection details).

    – Tim Friske
    Jul 30 '18 at 20:49











  • I think I figured out the issue, see A'er.

    – slm
    Jul 30 '18 at 23:21

















@slm: I was already aware of the answer unix.stackexchange.com/questions/24005/… but it doesn't suffice my needs. I therefore chose a very specific title for this question. Basically how to accomplish closing an OpenSSH control master connection without lsof or fuser. Maybe I should have further restricted it to without knowing the destination host (connection details).

– Tim Friske
Jul 30 '18 at 20:49





@slm: I was already aware of the answer unix.stackexchange.com/questions/24005/… but it doesn't suffice my needs. I therefore chose a very specific title for this question. Basically how to accomplish closing an OpenSSH control master connection without lsof or fuser. Maybe I should have further restricted it to without knowing the destination host (connection details).

– Tim Friske
Jul 30 '18 at 20:49













I think I figured out the issue, see A'er.

– slm
Jul 30 '18 at 23:21





I think I figured out the issue, see A'er.

– slm
Jul 30 '18 at 23:21










2 Answers
2






active

oldest

votes


















5














This works for me using just the socket file for the control master:



$ ssh -o ControlPath=~/.ssh/<controlfile> -O check <bogus arg>


NOTE: You can also use ssh -S ~/.ssh/<controlfile> ... as well, which is a bit shorter form of the above.



Example



Here's an example where I've already established a connection to a remote server:



$ ssh -S ~/.ssh/master-57db26a0499dfd881986e23a2e4dd5c5c63e26c2 -O check blah
Master running (pid=89228)
$


And with it disconnected:



$ ssh -S ~/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74 -O check blah
Control socket connect(/Users/user1/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74): No such file or directory
$


If it were still connected, this would force it to exit immediately:



$ ssh -S ~/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74 -O exit blah
Exit request sent.
$


It's unclear to me, but it would appear to potentially be a bug in ssh that it requires an additional argument at the end, even though blah is meaningless in the context of the switches I'm using.



Without it gives me this:



$ ssh -S ~/.ssh/master-57db26a0499dfd881986e23a2e4dd5c5c63e26c2 -O check
usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
[-D [bind_address:]port] [-E log_file] [-e escape_char]
[-F configfile] [-I pkcs11] [-i identity_file]
[-L [bind_address:]port:host:hostport] [-l login_name] [-m mac_spec]
[-O ctl_cmd] [-o option] [-p port]
[-Q cipher | cipher-auth | mac | kex | key]
[-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port]
[-w local_tun[:remote_tun]] [user@]hostname [command]


Version info



OSX

$ ssh -V
OpenSSH_6.9p1, LibreSSL 2.1.8


CentOS 7.x

$ ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017


I confirmed that on both of these versions, the need for the additional bogus argument was required.



UPDATE #1



I raised this as a potential bug to the OpenSSH upstream and they replied as follows:




Yes - this is intentional.



ControlPath may contain %-expansions that need a hostname to expand fully.



We could conceivably check to see whether ControlPath actually needs this and make the hostname optional but 1) ControlPaths that use %h are common and 2) I'd rather not make the argument parsing code more of a maze than it already is.




References




  • How to tell if an ssh ControlMaster connection is in use

  • How to close (kill) ssh ControlMaster connections manually






share|improve this answer


























  • The host argument at the end tells ssh what ControlMaster socket to remove if the ControlMaster is set up in a .ssh/config file. I could do ssh myhost (which sets of a ControlMaster socket) and later ssh -O exit myhost while still having other sockets active for other hosts in my configuration file.

    – Kusalananda
    Aug 10 '18 at 19:51













  • Right, that's was the feedback I received and what was described in the scenario form the upstream.

    – slm
    Aug 10 '18 at 19:52



















0














I wrote a utility that eases management of SSH ControlMaster connections. It's called cmc:
TimidRobot/cmc: ControlMaster Controller - Eases management of SSH ControlMaster connections.






share|improve this answer


























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f459450%2fhow-to-exit-openssh-control-master-process-without-using-lsof-or-fuser%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5














    This works for me using just the socket file for the control master:



    $ ssh -o ControlPath=~/.ssh/<controlfile> -O check <bogus arg>


    NOTE: You can also use ssh -S ~/.ssh/<controlfile> ... as well, which is a bit shorter form of the above.



    Example



    Here's an example where I've already established a connection to a remote server:



    $ ssh -S ~/.ssh/master-57db26a0499dfd881986e23a2e4dd5c5c63e26c2 -O check blah
    Master running (pid=89228)
    $


    And with it disconnected:



    $ ssh -S ~/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74 -O check blah
    Control socket connect(/Users/user1/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74): No such file or directory
    $


    If it were still connected, this would force it to exit immediately:



    $ ssh -S ~/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74 -O exit blah
    Exit request sent.
    $


    It's unclear to me, but it would appear to potentially be a bug in ssh that it requires an additional argument at the end, even though blah is meaningless in the context of the switches I'm using.



    Without it gives me this:



    $ ssh -S ~/.ssh/master-57db26a0499dfd881986e23a2e4dd5c5c63e26c2 -O check
    usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
    [-D [bind_address:]port] [-E log_file] [-e escape_char]
    [-F configfile] [-I pkcs11] [-i identity_file]
    [-L [bind_address:]port:host:hostport] [-l login_name] [-m mac_spec]
    [-O ctl_cmd] [-o option] [-p port]
    [-Q cipher | cipher-auth | mac | kex | key]
    [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port]
    [-w local_tun[:remote_tun]] [user@]hostname [command]


    Version info



    OSX

    $ ssh -V
    OpenSSH_6.9p1, LibreSSL 2.1.8


    CentOS 7.x

    $ ssh -V
    OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017


    I confirmed that on both of these versions, the need for the additional bogus argument was required.



    UPDATE #1



    I raised this as a potential bug to the OpenSSH upstream and they replied as follows:




    Yes - this is intentional.



    ControlPath may contain %-expansions that need a hostname to expand fully.



    We could conceivably check to see whether ControlPath actually needs this and make the hostname optional but 1) ControlPaths that use %h are common and 2) I'd rather not make the argument parsing code more of a maze than it already is.




    References




    • How to tell if an ssh ControlMaster connection is in use

    • How to close (kill) ssh ControlMaster connections manually






    share|improve this answer


























    • The host argument at the end tells ssh what ControlMaster socket to remove if the ControlMaster is set up in a .ssh/config file. I could do ssh myhost (which sets of a ControlMaster socket) and later ssh -O exit myhost while still having other sockets active for other hosts in my configuration file.

      – Kusalananda
      Aug 10 '18 at 19:51













    • Right, that's was the feedback I received and what was described in the scenario form the upstream.

      – slm
      Aug 10 '18 at 19:52
















    5














    This works for me using just the socket file for the control master:



    $ ssh -o ControlPath=~/.ssh/<controlfile> -O check <bogus arg>


    NOTE: You can also use ssh -S ~/.ssh/<controlfile> ... as well, which is a bit shorter form of the above.



    Example



    Here's an example where I've already established a connection to a remote server:



    $ ssh -S ~/.ssh/master-57db26a0499dfd881986e23a2e4dd5c5c63e26c2 -O check blah
    Master running (pid=89228)
    $


    And with it disconnected:



    $ ssh -S ~/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74 -O check blah
    Control socket connect(/Users/user1/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74): No such file or directory
    $


    If it were still connected, this would force it to exit immediately:



    $ ssh -S ~/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74 -O exit blah
    Exit request sent.
    $


    It's unclear to me, but it would appear to potentially be a bug in ssh that it requires an additional argument at the end, even though blah is meaningless in the context of the switches I'm using.



    Without it gives me this:



    $ ssh -S ~/.ssh/master-57db26a0499dfd881986e23a2e4dd5c5c63e26c2 -O check
    usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
    [-D [bind_address:]port] [-E log_file] [-e escape_char]
    [-F configfile] [-I pkcs11] [-i identity_file]
    [-L [bind_address:]port:host:hostport] [-l login_name] [-m mac_spec]
    [-O ctl_cmd] [-o option] [-p port]
    [-Q cipher | cipher-auth | mac | kex | key]
    [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port]
    [-w local_tun[:remote_tun]] [user@]hostname [command]


    Version info



    OSX

    $ ssh -V
    OpenSSH_6.9p1, LibreSSL 2.1.8


    CentOS 7.x

    $ ssh -V
    OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017


    I confirmed that on both of these versions, the need for the additional bogus argument was required.



    UPDATE #1



    I raised this as a potential bug to the OpenSSH upstream and they replied as follows:




    Yes - this is intentional.



    ControlPath may contain %-expansions that need a hostname to expand fully.



    We could conceivably check to see whether ControlPath actually needs this and make the hostname optional but 1) ControlPaths that use %h are common and 2) I'd rather not make the argument parsing code more of a maze than it already is.




    References




    • How to tell if an ssh ControlMaster connection is in use

    • How to close (kill) ssh ControlMaster connections manually






    share|improve this answer


























    • The host argument at the end tells ssh what ControlMaster socket to remove if the ControlMaster is set up in a .ssh/config file. I could do ssh myhost (which sets of a ControlMaster socket) and later ssh -O exit myhost while still having other sockets active for other hosts in my configuration file.

      – Kusalananda
      Aug 10 '18 at 19:51













    • Right, that's was the feedback I received and what was described in the scenario form the upstream.

      – slm
      Aug 10 '18 at 19:52














    5












    5








    5







    This works for me using just the socket file for the control master:



    $ ssh -o ControlPath=~/.ssh/<controlfile> -O check <bogus arg>


    NOTE: You can also use ssh -S ~/.ssh/<controlfile> ... as well, which is a bit shorter form of the above.



    Example



    Here's an example where I've already established a connection to a remote server:



    $ ssh -S ~/.ssh/master-57db26a0499dfd881986e23a2e4dd5c5c63e26c2 -O check blah
    Master running (pid=89228)
    $


    And with it disconnected:



    $ ssh -S ~/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74 -O check blah
    Control socket connect(/Users/user1/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74): No such file or directory
    $


    If it were still connected, this would force it to exit immediately:



    $ ssh -S ~/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74 -O exit blah
    Exit request sent.
    $


    It's unclear to me, but it would appear to potentially be a bug in ssh that it requires an additional argument at the end, even though blah is meaningless in the context of the switches I'm using.



    Without it gives me this:



    $ ssh -S ~/.ssh/master-57db26a0499dfd881986e23a2e4dd5c5c63e26c2 -O check
    usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
    [-D [bind_address:]port] [-E log_file] [-e escape_char]
    [-F configfile] [-I pkcs11] [-i identity_file]
    [-L [bind_address:]port:host:hostport] [-l login_name] [-m mac_spec]
    [-O ctl_cmd] [-o option] [-p port]
    [-Q cipher | cipher-auth | mac | kex | key]
    [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port]
    [-w local_tun[:remote_tun]] [user@]hostname [command]


    Version info



    OSX

    $ ssh -V
    OpenSSH_6.9p1, LibreSSL 2.1.8


    CentOS 7.x

    $ ssh -V
    OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017


    I confirmed that on both of these versions, the need for the additional bogus argument was required.



    UPDATE #1



    I raised this as a potential bug to the OpenSSH upstream and they replied as follows:




    Yes - this is intentional.



    ControlPath may contain %-expansions that need a hostname to expand fully.



    We could conceivably check to see whether ControlPath actually needs this and make the hostname optional but 1) ControlPaths that use %h are common and 2) I'd rather not make the argument parsing code more of a maze than it already is.




    References




    • How to tell if an ssh ControlMaster connection is in use

    • How to close (kill) ssh ControlMaster connections manually






    share|improve this answer















    This works for me using just the socket file for the control master:



    $ ssh -o ControlPath=~/.ssh/<controlfile> -O check <bogus arg>


    NOTE: You can also use ssh -S ~/.ssh/<controlfile> ... as well, which is a bit shorter form of the above.



    Example



    Here's an example where I've already established a connection to a remote server:



    $ ssh -S ~/.ssh/master-57db26a0499dfd881986e23a2e4dd5c5c63e26c2 -O check blah
    Master running (pid=89228)
    $


    And with it disconnected:



    $ ssh -S ~/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74 -O check blah
    Control socket connect(/Users/user1/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74): No such file or directory
    $


    If it were still connected, this would force it to exit immediately:



    $ ssh -S ~/.ssh/master-66496a62823573e4760469df70e57ce4c15afd74 -O exit blah
    Exit request sent.
    $


    It's unclear to me, but it would appear to potentially be a bug in ssh that it requires an additional argument at the end, even though blah is meaningless in the context of the switches I'm using.



    Without it gives me this:



    $ ssh -S ~/.ssh/master-57db26a0499dfd881986e23a2e4dd5c5c63e26c2 -O check
    usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
    [-D [bind_address:]port] [-E log_file] [-e escape_char]
    [-F configfile] [-I pkcs11] [-i identity_file]
    [-L [bind_address:]port:host:hostport] [-l login_name] [-m mac_spec]
    [-O ctl_cmd] [-o option] [-p port]
    [-Q cipher | cipher-auth | mac | kex | key]
    [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port]
    [-w local_tun[:remote_tun]] [user@]hostname [command]


    Version info



    OSX

    $ ssh -V
    OpenSSH_6.9p1, LibreSSL 2.1.8


    CentOS 7.x

    $ ssh -V
    OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017


    I confirmed that on both of these versions, the need for the additional bogus argument was required.



    UPDATE #1



    I raised this as a potential bug to the OpenSSH upstream and they replied as follows:




    Yes - this is intentional.



    ControlPath may contain %-expansions that need a hostname to expand fully.



    We could conceivably check to see whether ControlPath actually needs this and make the hostname optional but 1) ControlPaths that use %h are common and 2) I'd rather not make the argument parsing code more of a maze than it already is.




    References




    • How to tell if an ssh ControlMaster connection is in use

    • How to close (kill) ssh ControlMaster connections manually







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 1 hour ago

























    answered Jul 30 '18 at 23:20









    slmslm

    263k73 gold badges571 silver badges715 bronze badges




    263k73 gold badges571 silver badges715 bronze badges













    • The host argument at the end tells ssh what ControlMaster socket to remove if the ControlMaster is set up in a .ssh/config file. I could do ssh myhost (which sets of a ControlMaster socket) and later ssh -O exit myhost while still having other sockets active for other hosts in my configuration file.

      – Kusalananda
      Aug 10 '18 at 19:51













    • Right, that's was the feedback I received and what was described in the scenario form the upstream.

      – slm
      Aug 10 '18 at 19:52



















    • The host argument at the end tells ssh what ControlMaster socket to remove if the ControlMaster is set up in a .ssh/config file. I could do ssh myhost (which sets of a ControlMaster socket) and later ssh -O exit myhost while still having other sockets active for other hosts in my configuration file.

      – Kusalananda
      Aug 10 '18 at 19:51













    • Right, that's was the feedback I received and what was described in the scenario form the upstream.

      – slm
      Aug 10 '18 at 19:52

















    The host argument at the end tells ssh what ControlMaster socket to remove if the ControlMaster is set up in a .ssh/config file. I could do ssh myhost (which sets of a ControlMaster socket) and later ssh -O exit myhost while still having other sockets active for other hosts in my configuration file.

    – Kusalananda
    Aug 10 '18 at 19:51







    The host argument at the end tells ssh what ControlMaster socket to remove if the ControlMaster is set up in a .ssh/config file. I could do ssh myhost (which sets of a ControlMaster socket) and later ssh -O exit myhost while still having other sockets active for other hosts in my configuration file.

    – Kusalananda
    Aug 10 '18 at 19:51















    Right, that's was the feedback I received and what was described in the scenario form the upstream.

    – slm
    Aug 10 '18 at 19:52





    Right, that's was the feedback I received and what was described in the scenario form the upstream.

    – slm
    Aug 10 '18 at 19:52













    0














    I wrote a utility that eases management of SSH ControlMaster connections. It's called cmc:
    TimidRobot/cmc: ControlMaster Controller - Eases management of SSH ControlMaster connections.






    share|improve this answer




























      0














      I wrote a utility that eases management of SSH ControlMaster connections. It's called cmc:
      TimidRobot/cmc: ControlMaster Controller - Eases management of SSH ControlMaster connections.






      share|improve this answer


























        0












        0








        0







        I wrote a utility that eases management of SSH ControlMaster connections. It's called cmc:
        TimidRobot/cmc: ControlMaster Controller - Eases management of SSH ControlMaster connections.






        share|improve this answer













        I wrote a utility that eases management of SSH ControlMaster connections. It's called cmc:
        TimidRobot/cmc: ControlMaster Controller - Eases management of SSH ControlMaster connections.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 12 at 16:02









        TimZehtaTimZehta

        2112 silver badges3 bronze badges




        2112 silver badges3 bronze badges






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f459450%2fhow-to-exit-openssh-control-master-process-without-using-lsof-or-fuser%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

            Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

            Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...