SSH sessions hang on shutdown/rebootOpenSSH 6.7 end of sessionCentos 5 VPS: sshd freezesHow to automate SSH login with password?ssh returns “Bad owner or permissions on ~/.ssh/config”AT&T U-verse IRC, SSH, etc. sessions droppingTCP Sessions Hanging with Debian and iptablesSSH on Debian: Password prompt hangSSH file transfers hang after ~700KBFrequent interruptions of SSH connection to VPSGracefully logout all connected ssh users on rebootOpenSSH 6.7 end of session

Why is there no current between two capacitors connected in series?

1950s or earlier book with electrical currents living on Pluto

tikz: 5 squares on a row, roman numbered 1 -> 5

Parse a C++14 integer literal

How to become an Editorial board member?

Best practice for printing and evaluating formulas with the minimal coding

What does it mean to "take the Cross"

How could the B-29 bomber back up under its own power?

How can I prevent Bash expansion from passing files starting with "-" as argument?

How do you cope with rejection?

Was murdering a slave illegal in American slavery, and if so, what punishments were given for it?

What variables do I have to take into consideration when I homebrew armour?

On a piano, are the effects of holding notes and the sustain pedal the same for a single chord?

Department head said that group project may be rejected. How to mitigate?

Separate the element after every 2nd ',' and push into next row in bash

Is there any mention of ghosts who live outside the Hogwarts castle?

What are the domains of the multiplication and unit morphisms of a monoid object?

Germany rejected my entry to Schengen countries

Mikrokosmos, BB 105, Vol. 1: No. 17 Contrary Motion (1) - Can't understand the structure

Presenting 2 results for one variable using a left brace

If you attack a Tarrasque while swallowed, what AC do you need to beat to hit it?

Does science define life as "beginning at conception"?

Schwa-less Polysyllabic German Noun Stems of Germanic Origin

How should I mix small caps with digits or symbols?



SSH sessions hang on shutdown/reboot


OpenSSH 6.7 end of sessionCentos 5 VPS: sshd freezesHow to automate SSH login with password?ssh returns “Bad owner or permissions on ~/.ssh/config”AT&T U-verse IRC, SSH, etc. sessions droppingTCP Sessions Hanging with Debian and iptablesSSH on Debian: Password prompt hangSSH file transfers hang after ~700KBFrequent interruptions of SSH connection to VPSGracefully logout all connected ssh users on rebootOpenSSH 6.7 end of session






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








12















I have a server that runs Debian and sshd on it, and in case I need to reboot the server my SSH session hangs at client side until TCP timeout. I assume this is because when sshd is being terminated it does not explicitly close open SSH sessions to the host. What should I do to make sshd first disconnect everyone, then terminate itself as normal? So far I don't see a parameter in man sshd_config that's related to shutsown behavior.










share|improve this question
























  • When all else fails, you can kill an SSH client at any time by pressing [Enter] [~] [.]. Explanation on how to actually solve your problem coming up as well.

    – n.st
    Jul 17 '15 at 9:05


















12















I have a server that runs Debian and sshd on it, and in case I need to reboot the server my SSH session hangs at client side until TCP timeout. I assume this is because when sshd is being terminated it does not explicitly close open SSH sessions to the host. What should I do to make sshd first disconnect everyone, then terminate itself as normal? So far I don't see a parameter in man sshd_config that's related to shutsown behavior.










share|improve this question
























  • When all else fails, you can kill an SSH client at any time by pressing [Enter] [~] [.]. Explanation on how to actually solve your problem coming up as well.

    – n.st
    Jul 17 '15 at 9:05














12












12








12


9






I have a server that runs Debian and sshd on it, and in case I need to reboot the server my SSH session hangs at client side until TCP timeout. I assume this is because when sshd is being terminated it does not explicitly close open SSH sessions to the host. What should I do to make sshd first disconnect everyone, then terminate itself as normal? So far I don't see a parameter in man sshd_config that's related to shutsown behavior.










share|improve this question
















I have a server that runs Debian and sshd on it, and in case I need to reboot the server my SSH session hangs at client side until TCP timeout. I assume this is because when sshd is being terminated it does not explicitly close open SSH sessions to the host. What should I do to make sshd first disconnect everyone, then terminate itself as normal? So far I don't see a parameter in man sshd_config that's related to shutsown behavior.







ssh debian systemd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 17 '15 at 9:34









n.st

604514




604514










asked Jul 17 '15 at 8:16









VesperVesper

4811422




4811422












  • When all else fails, you can kill an SSH client at any time by pressing [Enter] [~] [.]. Explanation on how to actually solve your problem coming up as well.

    – n.st
    Jul 17 '15 at 9:05


















  • When all else fails, you can kill an SSH client at any time by pressing [Enter] [~] [.]. Explanation on how to actually solve your problem coming up as well.

    – n.st
    Jul 17 '15 at 9:05

















When all else fails, you can kill an SSH client at any time by pressing [Enter] [~] [.]. Explanation on how to actually solve your problem coming up as well.

– n.st
Jul 17 '15 at 9:05






When all else fails, you can kill an SSH client at any time by pressing [Enter] [~] [.]. Explanation on how to actually solve your problem coming up as well.

– n.st
Jul 17 '15 at 9:05











6 Answers
6






active

oldest

votes


















29














When you shutdown or reboot your system, systemd tries to stop all services as fast as it can. That involves bringing down the network and terminating all processes that are still alive -- usually in that order. So when systemd kills the forked SSH processes that are handling your SSH sessions, the network connection is already disabled and they have no way of closing the client connection gracefully.



Your first thought might be to just kill all SSH processes as the first step during shutdown, and there are quite a few systemd service files out there that do just that.



But there is of course a neater solution (how it's "supposed" to be done): systemd-logind.
systemd-logind keeps track of active user sessions (local and SSH ones) and assigns all processes spawned within them to so-called "slices". That way, when the system is shut down, systemd can just SIGTERM everything inside the user slices (which includes the forked SSH process that's handing a particular session) and then continue shutting down services and the network.



systemd-logind requires a PAM module to get notified of new user sessions and you'll need dbus to use loginctl to check its status, so install both of those:



apt-get install libpam-systemd dbus


Be sure your /etc/ssh/sshd_config is actually going to use the module with UsePAM yes.






share|improve this answer

























  • Okay, goal achieved, and thanks for the explanation. (Although I'd like some way of dependency control for shutdown, so that everything is first SIGTERM'd while being able to finish their work, this can do as a layered solution.)

    – Vesper
    Aug 3 '15 at 15:09











  • For some reason I wasn't notified about the answer while visiting only StackOverflow. Weird.

    – Vesper
    Aug 3 '15 at 15:10






  • 1





    So, for short, just to shave few seconds at shutdown, we have to install a whole load of crap just to have our connections terminated properly ? Seriously ? This is getting awry. We're doomed.

    – leucos
    Jun 29 '16 at 9:31






  • 3





    Note that tjhe first reboot after installing libpam-systemd and dbus would still leave your SSH session hanging. To avoid that, instead of reboot, do a shutdown -r which defaults to a 1 minute delay, leaving you time to close the SSH session.

    – mivk
    Oct 30 '16 at 19:20


















9














This is something you need to set on the client side, not the server side. Edit your ~/.ssh/config to contain



ServerAliveInterval 15
ServerAliveCountMax 5


This means that after 15 seconds of inactivity, your client will send a message to the server. If it doesn't get any response, it will try again up to 5 times, and when it still doesn't get an answer, it'll close the session.






share|improve this answer


















  • 2





    This will result in 75s delay before ssh client reports server dead. Right?

    – Vesper
    Jul 17 '15 at 8:39






  • 1





    Yes, and you can adjust the parameters to get shorter timeout.

    – Tero Kilkanen
    Jul 17 '15 at 9:12











  • This solved the problem for me. Such an irritating problem.

    – Justin Andrusk
    Jun 28 '16 at 1:09


















4














This behaviour is reported on this Debian Bug, you only need to setup correctly the shutdown scripts shiped with the package because, automatically, they aren't copied by default:



cp /usr/share/doc/openssh-client/examples/ssh-session-cleanup.service /etc/systemd/system/
systemctl enable ssh-session-cleanup.service





share|improve this answer






























    1














    You can specify the options that Jenny D talked about in her answer just for one ssh command, such as



    ssh -t -o ServerAliveInterval=1 -o ServerAliveCountMax=1 user@host sudo poweroff


    if you do that often, you can script it.






    share|improve this answer






























      0














      Works for me with lshd. So the solution would be



      apt install lsh-server
      apt remove openssh-server





      share|improve this answer






























        0














        sadly serverfault didn't let me answer in thread cause by too few points since years.
        But I don't need to spam in other blogs to get the unlocking ^^... so as dedicated answer:



        As Rfraile mentioned



        cp /usr/share/doc/openssh-client/examples/ssh-session-cleanup.service /etc/systemd/system/
        systemctl enable ssh-session-cleanup.service


        works. To be using it without reboot the instance/server you should do additional tasks:



        systemctl daemon-reload
        systemctl start ssh-session-cleanup.service


        so the service is registered and started and systemd needs to stop it for reboot/shutdown purposes.






        share|improve this answer























        • So are you just repeating another answer?

          – RalfFriedl
          May 7 at 18:45











        • No? I used the 2 lines only as reference for the upper reply because I can't reply yet as written. I added the necessary steps to use it without reboot. This may be given also in another question thread but that I haven't checked out.

          – Reiner030
          May 8 at 19:24












        Your Answer








        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "2"
        ;
        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: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        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%2fserverfault.com%2fquestions%2f706475%2fssh-sessions-hang-on-shutdown-reboot%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        6 Answers
        6






        active

        oldest

        votes








        6 Answers
        6






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        29














        When you shutdown or reboot your system, systemd tries to stop all services as fast as it can. That involves bringing down the network and terminating all processes that are still alive -- usually in that order. So when systemd kills the forked SSH processes that are handling your SSH sessions, the network connection is already disabled and they have no way of closing the client connection gracefully.



        Your first thought might be to just kill all SSH processes as the first step during shutdown, and there are quite a few systemd service files out there that do just that.



        But there is of course a neater solution (how it's "supposed" to be done): systemd-logind.
        systemd-logind keeps track of active user sessions (local and SSH ones) and assigns all processes spawned within them to so-called "slices". That way, when the system is shut down, systemd can just SIGTERM everything inside the user slices (which includes the forked SSH process that's handing a particular session) and then continue shutting down services and the network.



        systemd-logind requires a PAM module to get notified of new user sessions and you'll need dbus to use loginctl to check its status, so install both of those:



        apt-get install libpam-systemd dbus


        Be sure your /etc/ssh/sshd_config is actually going to use the module with UsePAM yes.






        share|improve this answer

























        • Okay, goal achieved, and thanks for the explanation. (Although I'd like some way of dependency control for shutdown, so that everything is first SIGTERM'd while being able to finish their work, this can do as a layered solution.)

          – Vesper
          Aug 3 '15 at 15:09











        • For some reason I wasn't notified about the answer while visiting only StackOverflow. Weird.

          – Vesper
          Aug 3 '15 at 15:10






        • 1





          So, for short, just to shave few seconds at shutdown, we have to install a whole load of crap just to have our connections terminated properly ? Seriously ? This is getting awry. We're doomed.

          – leucos
          Jun 29 '16 at 9:31






        • 3





          Note that tjhe first reboot after installing libpam-systemd and dbus would still leave your SSH session hanging. To avoid that, instead of reboot, do a shutdown -r which defaults to a 1 minute delay, leaving you time to close the SSH session.

          – mivk
          Oct 30 '16 at 19:20















        29














        When you shutdown or reboot your system, systemd tries to stop all services as fast as it can. That involves bringing down the network and terminating all processes that are still alive -- usually in that order. So when systemd kills the forked SSH processes that are handling your SSH sessions, the network connection is already disabled and they have no way of closing the client connection gracefully.



        Your first thought might be to just kill all SSH processes as the first step during shutdown, and there are quite a few systemd service files out there that do just that.



        But there is of course a neater solution (how it's "supposed" to be done): systemd-logind.
        systemd-logind keeps track of active user sessions (local and SSH ones) and assigns all processes spawned within them to so-called "slices". That way, when the system is shut down, systemd can just SIGTERM everything inside the user slices (which includes the forked SSH process that's handing a particular session) and then continue shutting down services and the network.



        systemd-logind requires a PAM module to get notified of new user sessions and you'll need dbus to use loginctl to check its status, so install both of those:



        apt-get install libpam-systemd dbus


        Be sure your /etc/ssh/sshd_config is actually going to use the module with UsePAM yes.






        share|improve this answer

























        • Okay, goal achieved, and thanks for the explanation. (Although I'd like some way of dependency control for shutdown, so that everything is first SIGTERM'd while being able to finish their work, this can do as a layered solution.)

          – Vesper
          Aug 3 '15 at 15:09











        • For some reason I wasn't notified about the answer while visiting only StackOverflow. Weird.

          – Vesper
          Aug 3 '15 at 15:10






        • 1





          So, for short, just to shave few seconds at shutdown, we have to install a whole load of crap just to have our connections terminated properly ? Seriously ? This is getting awry. We're doomed.

          – leucos
          Jun 29 '16 at 9:31






        • 3





          Note that tjhe first reboot after installing libpam-systemd and dbus would still leave your SSH session hanging. To avoid that, instead of reboot, do a shutdown -r which defaults to a 1 minute delay, leaving you time to close the SSH session.

          – mivk
          Oct 30 '16 at 19:20













        29












        29








        29







        When you shutdown or reboot your system, systemd tries to stop all services as fast as it can. That involves bringing down the network and terminating all processes that are still alive -- usually in that order. So when systemd kills the forked SSH processes that are handling your SSH sessions, the network connection is already disabled and they have no way of closing the client connection gracefully.



        Your first thought might be to just kill all SSH processes as the first step during shutdown, and there are quite a few systemd service files out there that do just that.



        But there is of course a neater solution (how it's "supposed" to be done): systemd-logind.
        systemd-logind keeps track of active user sessions (local and SSH ones) and assigns all processes spawned within them to so-called "slices". That way, when the system is shut down, systemd can just SIGTERM everything inside the user slices (which includes the forked SSH process that's handing a particular session) and then continue shutting down services and the network.



        systemd-logind requires a PAM module to get notified of new user sessions and you'll need dbus to use loginctl to check its status, so install both of those:



        apt-get install libpam-systemd dbus


        Be sure your /etc/ssh/sshd_config is actually going to use the module with UsePAM yes.






        share|improve this answer















        When you shutdown or reboot your system, systemd tries to stop all services as fast as it can. That involves bringing down the network and terminating all processes that are still alive -- usually in that order. So when systemd kills the forked SSH processes that are handling your SSH sessions, the network connection is already disabled and they have no way of closing the client connection gracefully.



        Your first thought might be to just kill all SSH processes as the first step during shutdown, and there are quite a few systemd service files out there that do just that.



        But there is of course a neater solution (how it's "supposed" to be done): systemd-logind.
        systemd-logind keeps track of active user sessions (local and SSH ones) and assigns all processes spawned within them to so-called "slices". That way, when the system is shut down, systemd can just SIGTERM everything inside the user slices (which includes the forked SSH process that's handing a particular session) and then continue shutting down services and the network.



        systemd-logind requires a PAM module to get notified of new user sessions and you'll need dbus to use loginctl to check its status, so install both of those:



        apt-get install libpam-systemd dbus


        Be sure your /etc/ssh/sshd_config is actually going to use the module with UsePAM yes.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 7 '17 at 2:45









        Tullo_x86

        1034




        1034










        answered Jul 17 '15 at 9:20









        n.stn.st

        604514




        604514












        • Okay, goal achieved, and thanks for the explanation. (Although I'd like some way of dependency control for shutdown, so that everything is first SIGTERM'd while being able to finish their work, this can do as a layered solution.)

          – Vesper
          Aug 3 '15 at 15:09











        • For some reason I wasn't notified about the answer while visiting only StackOverflow. Weird.

          – Vesper
          Aug 3 '15 at 15:10






        • 1





          So, for short, just to shave few seconds at shutdown, we have to install a whole load of crap just to have our connections terminated properly ? Seriously ? This is getting awry. We're doomed.

          – leucos
          Jun 29 '16 at 9:31






        • 3





          Note that tjhe first reboot after installing libpam-systemd and dbus would still leave your SSH session hanging. To avoid that, instead of reboot, do a shutdown -r which defaults to a 1 minute delay, leaving you time to close the SSH session.

          – mivk
          Oct 30 '16 at 19:20

















        • Okay, goal achieved, and thanks for the explanation. (Although I'd like some way of dependency control for shutdown, so that everything is first SIGTERM'd while being able to finish their work, this can do as a layered solution.)

          – Vesper
          Aug 3 '15 at 15:09











        • For some reason I wasn't notified about the answer while visiting only StackOverflow. Weird.

          – Vesper
          Aug 3 '15 at 15:10






        • 1





          So, for short, just to shave few seconds at shutdown, we have to install a whole load of crap just to have our connections terminated properly ? Seriously ? This is getting awry. We're doomed.

          – leucos
          Jun 29 '16 at 9:31






        • 3





          Note that tjhe first reboot after installing libpam-systemd and dbus would still leave your SSH session hanging. To avoid that, instead of reboot, do a shutdown -r which defaults to a 1 minute delay, leaving you time to close the SSH session.

          – mivk
          Oct 30 '16 at 19:20
















        Okay, goal achieved, and thanks for the explanation. (Although I'd like some way of dependency control for shutdown, so that everything is first SIGTERM'd while being able to finish their work, this can do as a layered solution.)

        – Vesper
        Aug 3 '15 at 15:09





        Okay, goal achieved, and thanks for the explanation. (Although I'd like some way of dependency control for shutdown, so that everything is first SIGTERM'd while being able to finish their work, this can do as a layered solution.)

        – Vesper
        Aug 3 '15 at 15:09













        For some reason I wasn't notified about the answer while visiting only StackOverflow. Weird.

        – Vesper
        Aug 3 '15 at 15:10





        For some reason I wasn't notified about the answer while visiting only StackOverflow. Weird.

        – Vesper
        Aug 3 '15 at 15:10




        1




        1





        So, for short, just to shave few seconds at shutdown, we have to install a whole load of crap just to have our connections terminated properly ? Seriously ? This is getting awry. We're doomed.

        – leucos
        Jun 29 '16 at 9:31





        So, for short, just to shave few seconds at shutdown, we have to install a whole load of crap just to have our connections terminated properly ? Seriously ? This is getting awry. We're doomed.

        – leucos
        Jun 29 '16 at 9:31




        3




        3





        Note that tjhe first reboot after installing libpam-systemd and dbus would still leave your SSH session hanging. To avoid that, instead of reboot, do a shutdown -r which defaults to a 1 minute delay, leaving you time to close the SSH session.

        – mivk
        Oct 30 '16 at 19:20





        Note that tjhe first reboot after installing libpam-systemd and dbus would still leave your SSH session hanging. To avoid that, instead of reboot, do a shutdown -r which defaults to a 1 minute delay, leaving you time to close the SSH session.

        – mivk
        Oct 30 '16 at 19:20













        9














        This is something you need to set on the client side, not the server side. Edit your ~/.ssh/config to contain



        ServerAliveInterval 15
        ServerAliveCountMax 5


        This means that after 15 seconds of inactivity, your client will send a message to the server. If it doesn't get any response, it will try again up to 5 times, and when it still doesn't get an answer, it'll close the session.






        share|improve this answer


















        • 2





          This will result in 75s delay before ssh client reports server dead. Right?

          – Vesper
          Jul 17 '15 at 8:39






        • 1





          Yes, and you can adjust the parameters to get shorter timeout.

          – Tero Kilkanen
          Jul 17 '15 at 9:12











        • This solved the problem for me. Such an irritating problem.

          – Justin Andrusk
          Jun 28 '16 at 1:09















        9














        This is something you need to set on the client side, not the server side. Edit your ~/.ssh/config to contain



        ServerAliveInterval 15
        ServerAliveCountMax 5


        This means that after 15 seconds of inactivity, your client will send a message to the server. If it doesn't get any response, it will try again up to 5 times, and when it still doesn't get an answer, it'll close the session.






        share|improve this answer


















        • 2





          This will result in 75s delay before ssh client reports server dead. Right?

          – Vesper
          Jul 17 '15 at 8:39






        • 1





          Yes, and you can adjust the parameters to get shorter timeout.

          – Tero Kilkanen
          Jul 17 '15 at 9:12











        • This solved the problem for me. Such an irritating problem.

          – Justin Andrusk
          Jun 28 '16 at 1:09













        9












        9








        9







        This is something you need to set on the client side, not the server side. Edit your ~/.ssh/config to contain



        ServerAliveInterval 15
        ServerAliveCountMax 5


        This means that after 15 seconds of inactivity, your client will send a message to the server. If it doesn't get any response, it will try again up to 5 times, and when it still doesn't get an answer, it'll close the session.






        share|improve this answer













        This is something you need to set on the client side, not the server side. Edit your ~/.ssh/config to contain



        ServerAliveInterval 15
        ServerAliveCountMax 5


        This means that after 15 seconds of inactivity, your client will send a message to the server. If it doesn't get any response, it will try again up to 5 times, and when it still doesn't get an answer, it'll close the session.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 17 '15 at 8:36









        Jenny DJenny D

        24.4k116296




        24.4k116296







        • 2





          This will result in 75s delay before ssh client reports server dead. Right?

          – Vesper
          Jul 17 '15 at 8:39






        • 1





          Yes, and you can adjust the parameters to get shorter timeout.

          – Tero Kilkanen
          Jul 17 '15 at 9:12











        • This solved the problem for me. Such an irritating problem.

          – Justin Andrusk
          Jun 28 '16 at 1:09












        • 2





          This will result in 75s delay before ssh client reports server dead. Right?

          – Vesper
          Jul 17 '15 at 8:39






        • 1





          Yes, and you can adjust the parameters to get shorter timeout.

          – Tero Kilkanen
          Jul 17 '15 at 9:12











        • This solved the problem for me. Such an irritating problem.

          – Justin Andrusk
          Jun 28 '16 at 1:09







        2




        2





        This will result in 75s delay before ssh client reports server dead. Right?

        – Vesper
        Jul 17 '15 at 8:39





        This will result in 75s delay before ssh client reports server dead. Right?

        – Vesper
        Jul 17 '15 at 8:39




        1




        1





        Yes, and you can adjust the parameters to get shorter timeout.

        – Tero Kilkanen
        Jul 17 '15 at 9:12





        Yes, and you can adjust the parameters to get shorter timeout.

        – Tero Kilkanen
        Jul 17 '15 at 9:12













        This solved the problem for me. Such an irritating problem.

        – Justin Andrusk
        Jun 28 '16 at 1:09





        This solved the problem for me. Such an irritating problem.

        – Justin Andrusk
        Jun 28 '16 at 1:09











        4














        This behaviour is reported on this Debian Bug, you only need to setup correctly the shutdown scripts shiped with the package because, automatically, they aren't copied by default:



        cp /usr/share/doc/openssh-client/examples/ssh-session-cleanup.service /etc/systemd/system/
        systemctl enable ssh-session-cleanup.service





        share|improve this answer



























          4














          This behaviour is reported on this Debian Bug, you only need to setup correctly the shutdown scripts shiped with the package because, automatically, they aren't copied by default:



          cp /usr/share/doc/openssh-client/examples/ssh-session-cleanup.service /etc/systemd/system/
          systemctl enable ssh-session-cleanup.service





          share|improve this answer

























            4












            4








            4







            This behaviour is reported on this Debian Bug, you only need to setup correctly the shutdown scripts shiped with the package because, automatically, they aren't copied by default:



            cp /usr/share/doc/openssh-client/examples/ssh-session-cleanup.service /etc/systemd/system/
            systemctl enable ssh-session-cleanup.service





            share|improve this answer













            This behaviour is reported on this Debian Bug, you only need to setup correctly the shutdown scripts shiped with the package because, automatically, they aren't copied by default:



            cp /usr/share/doc/openssh-client/examples/ssh-session-cleanup.service /etc/systemd/system/
            systemctl enable ssh-session-cleanup.service






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 18 at 11:37









            RfraileRfraile

            344210




            344210





















                1














                You can specify the options that Jenny D talked about in her answer just for one ssh command, such as



                ssh -t -o ServerAliveInterval=1 -o ServerAliveCountMax=1 user@host sudo poweroff


                if you do that often, you can script it.






                share|improve this answer



























                  1














                  You can specify the options that Jenny D talked about in her answer just for one ssh command, such as



                  ssh -t -o ServerAliveInterval=1 -o ServerAliveCountMax=1 user@host sudo poweroff


                  if you do that often, you can script it.






                  share|improve this answer

























                    1












                    1








                    1







                    You can specify the options that Jenny D talked about in her answer just for one ssh command, such as



                    ssh -t -o ServerAliveInterval=1 -o ServerAliveCountMax=1 user@host sudo poweroff


                    if you do that often, you can script it.






                    share|improve this answer













                    You can specify the options that Jenny D talked about in her answer just for one ssh command, such as



                    ssh -t -o ServerAliveInterval=1 -o ServerAliveCountMax=1 user@host sudo poweroff


                    if you do that often, you can script it.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Dec 4 '16 at 2:12









                    Diego MedagliaDiego Medaglia

                    286




                    286





















                        0














                        Works for me with lshd. So the solution would be



                        apt install lsh-server
                        apt remove openssh-server





                        share|improve this answer



























                          0














                          Works for me with lshd. So the solution would be



                          apt install lsh-server
                          apt remove openssh-server





                          share|improve this answer

























                            0












                            0








                            0







                            Works for me with lshd. So the solution would be



                            apt install lsh-server
                            apt remove openssh-server





                            share|improve this answer













                            Works for me with lshd. So the solution would be



                            apt install lsh-server
                            apt remove openssh-server






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Aug 3 '15 at 14:57









                            godgod

                            12117




                            12117





















                                0














                                sadly serverfault didn't let me answer in thread cause by too few points since years.
                                But I don't need to spam in other blogs to get the unlocking ^^... so as dedicated answer:



                                As Rfraile mentioned



                                cp /usr/share/doc/openssh-client/examples/ssh-session-cleanup.service /etc/systemd/system/
                                systemctl enable ssh-session-cleanup.service


                                works. To be using it without reboot the instance/server you should do additional tasks:



                                systemctl daemon-reload
                                systemctl start ssh-session-cleanup.service


                                so the service is registered and started and systemd needs to stop it for reboot/shutdown purposes.






                                share|improve this answer























                                • So are you just repeating another answer?

                                  – RalfFriedl
                                  May 7 at 18:45











                                • No? I used the 2 lines only as reference for the upper reply because I can't reply yet as written. I added the necessary steps to use it without reboot. This may be given also in another question thread but that I haven't checked out.

                                  – Reiner030
                                  May 8 at 19:24
















                                0














                                sadly serverfault didn't let me answer in thread cause by too few points since years.
                                But I don't need to spam in other blogs to get the unlocking ^^... so as dedicated answer:



                                As Rfraile mentioned



                                cp /usr/share/doc/openssh-client/examples/ssh-session-cleanup.service /etc/systemd/system/
                                systemctl enable ssh-session-cleanup.service


                                works. To be using it without reboot the instance/server you should do additional tasks:



                                systemctl daemon-reload
                                systemctl start ssh-session-cleanup.service


                                so the service is registered and started and systemd needs to stop it for reboot/shutdown purposes.






                                share|improve this answer























                                • So are you just repeating another answer?

                                  – RalfFriedl
                                  May 7 at 18:45











                                • No? I used the 2 lines only as reference for the upper reply because I can't reply yet as written. I added the necessary steps to use it without reboot. This may be given also in another question thread but that I haven't checked out.

                                  – Reiner030
                                  May 8 at 19:24














                                0












                                0








                                0







                                sadly serverfault didn't let me answer in thread cause by too few points since years.
                                But I don't need to spam in other blogs to get the unlocking ^^... so as dedicated answer:



                                As Rfraile mentioned



                                cp /usr/share/doc/openssh-client/examples/ssh-session-cleanup.service /etc/systemd/system/
                                systemctl enable ssh-session-cleanup.service


                                works. To be using it without reboot the instance/server you should do additional tasks:



                                systemctl daemon-reload
                                systemctl start ssh-session-cleanup.service


                                so the service is registered and started and systemd needs to stop it for reboot/shutdown purposes.






                                share|improve this answer













                                sadly serverfault didn't let me answer in thread cause by too few points since years.
                                But I don't need to spam in other blogs to get the unlocking ^^... so as dedicated answer:



                                As Rfraile mentioned



                                cp /usr/share/doc/openssh-client/examples/ssh-session-cleanup.service /etc/systemd/system/
                                systemctl enable ssh-session-cleanup.service


                                works. To be using it without reboot the instance/server you should do additional tasks:



                                systemctl daemon-reload
                                systemctl start ssh-session-cleanup.service


                                so the service is registered and started and systemd needs to stop it for reboot/shutdown purposes.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered May 7 at 16:55









                                Reiner030Reiner030

                                485




                                485












                                • So are you just repeating another answer?

                                  – RalfFriedl
                                  May 7 at 18:45











                                • No? I used the 2 lines only as reference for the upper reply because I can't reply yet as written. I added the necessary steps to use it without reboot. This may be given also in another question thread but that I haven't checked out.

                                  – Reiner030
                                  May 8 at 19:24


















                                • So are you just repeating another answer?

                                  – RalfFriedl
                                  May 7 at 18:45











                                • No? I used the 2 lines only as reference for the upper reply because I can't reply yet as written. I added the necessary steps to use it without reboot. This may be given also in another question thread but that I haven't checked out.

                                  – Reiner030
                                  May 8 at 19:24

















                                So are you just repeating another answer?

                                – RalfFriedl
                                May 7 at 18:45





                                So are you just repeating another answer?

                                – RalfFriedl
                                May 7 at 18:45













                                No? I used the 2 lines only as reference for the upper reply because I can't reply yet as written. I added the necessary steps to use it without reboot. This may be given also in another question thread but that I haven't checked out.

                                – Reiner030
                                May 8 at 19:24






                                No? I used the 2 lines only as reference for the upper reply because I can't reply yet as written. I added the necessary steps to use it without reboot. This may be given also in another question thread but that I haven't checked out.

                                – Reiner030
                                May 8 at 19:24


















                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Server Fault!


                                • 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%2fserverfault.com%2fquestions%2f706475%2fssh-sessions-hang-on-shutdown-reboot%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

                                Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

                                Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

                                Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020