How can I reconnect to a ssh session after a broken pipe?












23














So I was running apt-get upgrade on a server when the router decided it had been too long since it last made me angry: It dropped all connection. Moral of the story is to use screen a lot when you're on a bum router.



Anyway, I logged back in and found in htop that the process was still hanging there, still waiting for my Y/n to upgrade (hadn't hit it yet, luckily). Is there any way I can reattach to a session that had been broken off? I ended up just killing it since it wasn't in the middle of package management but it would be great to know for future reference.










share|improve this question




















  • 1




    I'm surprised the apt-get process was still running. It should have died along with the whole process chain up to SSH. I've noticed that do-dist-upgrade automatically starts in a screen/byobu session: maybe in some circumstances, apt-get does the same?
    – nfirvine
    Oct 2 '12 at 17:41
















23














So I was running apt-get upgrade on a server when the router decided it had been too long since it last made me angry: It dropped all connection. Moral of the story is to use screen a lot when you're on a bum router.



Anyway, I logged back in and found in htop that the process was still hanging there, still waiting for my Y/n to upgrade (hadn't hit it yet, luckily). Is there any way I can reattach to a session that had been broken off? I ended up just killing it since it wasn't in the middle of package management but it would be great to know for future reference.










share|improve this question




















  • 1




    I'm surprised the apt-get process was still running. It should have died along with the whole process chain up to SSH. I've noticed that do-dist-upgrade automatically starts in a screen/byobu session: maybe in some circumstances, apt-get does the same?
    – nfirvine
    Oct 2 '12 at 17:41














23












23








23


6





So I was running apt-get upgrade on a server when the router decided it had been too long since it last made me angry: It dropped all connection. Moral of the story is to use screen a lot when you're on a bum router.



Anyway, I logged back in and found in htop that the process was still hanging there, still waiting for my Y/n to upgrade (hadn't hit it yet, luckily). Is there any way I can reattach to a session that had been broken off? I ended up just killing it since it wasn't in the middle of package management but it would be great to know for future reference.










share|improve this question















So I was running apt-get upgrade on a server when the router decided it had been too long since it last made me angry: It dropped all connection. Moral of the story is to use screen a lot when you're on a bum router.



Anyway, I logged back in and found in htop that the process was still hanging there, still waiting for my Y/n to upgrade (hadn't hit it yet, luckily). Is there any way I can reattach to a session that had been broken off? I ended up just killing it since it wasn't in the middle of package management but it would be great to know for future reference.







ssh openssh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 27 '12 at 21:38









hexafraction

16.1k95385




16.1k95385










asked Sep 22 '12 at 3:49







user6658















  • 1




    I'm surprised the apt-get process was still running. It should have died along with the whole process chain up to SSH. I've noticed that do-dist-upgrade automatically starts in a screen/byobu session: maybe in some circumstances, apt-get does the same?
    – nfirvine
    Oct 2 '12 at 17:41














  • 1




    I'm surprised the apt-get process was still running. It should have died along with the whole process chain up to SSH. I've noticed that do-dist-upgrade automatically starts in a screen/byobu session: maybe in some circumstances, apt-get does the same?
    – nfirvine
    Oct 2 '12 at 17:41








1




1




I'm surprised the apt-get process was still running. It should have died along with the whole process chain up to SSH. I've noticed that do-dist-upgrade automatically starts in a screen/byobu session: maybe in some circumstances, apt-get does the same?
– nfirvine
Oct 2 '12 at 17:41




I'm surprised the apt-get process was still running. It should have died along with the whole process chain up to SSH. I've noticed that do-dist-upgrade automatically starts in a screen/byobu session: maybe in some circumstances, apt-get does the same?
– nfirvine
Oct 2 '12 at 17:41










3 Answers
3






active

oldest

votes


















14





+50









The answer to your proper question is: you can't. I think the main problem is that the authentication procedures will be out of sync. It Just Doesn't Work Like That.



As you have yourself noticed, the solution is to use screen when possible (by the way, tmux is an alternative to screen).






share|improve this answer























  • Well, thanks for confirming my suspicions.
    – user6658
    Sep 28 '12 at 16:54






  • 1




    But what if you have passwordless ssh? Can you do it then?
    – Sridhar-Sarnobat
    Aug 3 '13 at 17:17






  • 1




    byobu is a nice, easier to use front end to screen (or tmux) - definitely worth a look (:
    – drevicko
    Feb 15 '15 at 22:35



















8














For running long lasting processes, I use screen, or byobu if you want a more friendly interface.



For screen, you can use:



screen [program] [args]


This will run [program] and its [args] inside a screen session. Once the program is finished, the session is automatically closed. If you wish to keep the session after your program runs, just run screen without any arguments and a new prompt will appear inside the session. CTRL+A+D detaches the terminal from the current session.



To re-attach to a previous session:



screen -r


If there is only one session open, it will reattach immediately. If multiple sessions are ongoing, it will ask you which one you want to attach to. If you know the session name, you can just add it as an argument to this command line.



Byobu is a nice improvement. It's based on screen, but provides a bar at the bottom that shows all current sessions as tabs and gives easier shortcuts to move around those. You can:




  • F2 start a new session

  • F3 move to the next session tab on the left

  • F4 move to the next session tab on the right

  • F8 give a friendly name to the current session tab

  • F9 opens a options menu

  • CTRL+A+D detaches all sessions from the terminal.


WORD OF ADVICE: avoid leaving a session opened with the user root. If anyone gains access to your terminal (locally or remotely), they can easily re-attach to an ongoing session and use your system as root. If needed, it's best to start a session using a common user and sudo indivudual command lines as necessary.






share|improve this answer

















  • 1




    May I quote the OP: "Moral of the story is to use screen a lot". Apparently that was not the question here.
    – January
    Sep 28 '12 at 12:13










  • Thanks for the writeup but January was correct.
    – user6658
    Sep 28 '12 at 16:53










  • Use sudo screen <command> to setup a screen as root, which needs sudo access to reconnect to it. Far better than starting a screen normally, then changing to root within it.
    – djsmiley2k
    Aug 15 '13 at 11:31



















5














While you can't reattach to a broken SSH session, you can reparent the process running inside – functionally equivalent to what you want.



In your case, you would take over the apt-get process to be controlled from a new SSH session, screen session or the like. My favourite for this is the reptyr command:



$ sudo apt-get install reptyr
$ ps ax | grep apt-get
10626 pts/8 R+ 0:32 apt-get upgrade


Then, with the pid you found for your process:



$ reptyr 10626


After this stage, all your keyboard input goes to the program you took over. Unfortunately you will not see old output of the SSH session, such as the apt-get output asking you for confirmation.



There are multiple other tools that basically work the same as reptyr (that is, via ptrace debug attachment). See the following questions and answers where they are discussed:




  • How can I disown a running process and associate it to a new screen shell?

  • Resume command running in dropped SSH session


(Details: The reason you can't take over a SSH session this way is because a sshd process is not controlled by a host terminal, instead it provides the slave part of a terminal – a pts device – while the master part controlling it resides on the client machine, here with a broken-down SSH session in between. When you force taking over such a sshd process with reptyr -s <pid>, your keyboard input goes to that process, not its active child process. So a "Ctrl+Z" will simply kill off that sshd.)






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    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%2faskubuntu.com%2fquestions%2f191573%2fhow-can-i-reconnect-to-a-ssh-session-after-a-broken-pipe%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown
























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    14





    +50









    The answer to your proper question is: you can't. I think the main problem is that the authentication procedures will be out of sync. It Just Doesn't Work Like That.



    As you have yourself noticed, the solution is to use screen when possible (by the way, tmux is an alternative to screen).






    share|improve this answer























    • Well, thanks for confirming my suspicions.
      – user6658
      Sep 28 '12 at 16:54






    • 1




      But what if you have passwordless ssh? Can you do it then?
      – Sridhar-Sarnobat
      Aug 3 '13 at 17:17






    • 1




      byobu is a nice, easier to use front end to screen (or tmux) - definitely worth a look (:
      – drevicko
      Feb 15 '15 at 22:35
















    14





    +50









    The answer to your proper question is: you can't. I think the main problem is that the authentication procedures will be out of sync. It Just Doesn't Work Like That.



    As you have yourself noticed, the solution is to use screen when possible (by the way, tmux is an alternative to screen).






    share|improve this answer























    • Well, thanks for confirming my suspicions.
      – user6658
      Sep 28 '12 at 16:54






    • 1




      But what if you have passwordless ssh? Can you do it then?
      – Sridhar-Sarnobat
      Aug 3 '13 at 17:17






    • 1




      byobu is a nice, easier to use front end to screen (or tmux) - definitely worth a look (:
      – drevicko
      Feb 15 '15 at 22:35














    14





    +50







    14





    +50



    14




    +50




    The answer to your proper question is: you can't. I think the main problem is that the authentication procedures will be out of sync. It Just Doesn't Work Like That.



    As you have yourself noticed, the solution is to use screen when possible (by the way, tmux is an alternative to screen).






    share|improve this answer














    The answer to your proper question is: you can't. I think the main problem is that the authentication procedures will be out of sync. It Just Doesn't Work Like That.



    As you have yourself noticed, the solution is to use screen when possible (by the way, tmux is an alternative to screen).







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 17 '17 at 19:40









    phord

    12817




    12817










    answered Sep 28 '12 at 10:11









    January

    25k106688




    25k106688












    • Well, thanks for confirming my suspicions.
      – user6658
      Sep 28 '12 at 16:54






    • 1




      But what if you have passwordless ssh? Can you do it then?
      – Sridhar-Sarnobat
      Aug 3 '13 at 17:17






    • 1




      byobu is a nice, easier to use front end to screen (or tmux) - definitely worth a look (:
      – drevicko
      Feb 15 '15 at 22:35


















    • Well, thanks for confirming my suspicions.
      – user6658
      Sep 28 '12 at 16:54






    • 1




      But what if you have passwordless ssh? Can you do it then?
      – Sridhar-Sarnobat
      Aug 3 '13 at 17:17






    • 1




      byobu is a nice, easier to use front end to screen (or tmux) - definitely worth a look (:
      – drevicko
      Feb 15 '15 at 22:35
















    Well, thanks for confirming my suspicions.
    – user6658
    Sep 28 '12 at 16:54




    Well, thanks for confirming my suspicions.
    – user6658
    Sep 28 '12 at 16:54




    1




    1




    But what if you have passwordless ssh? Can you do it then?
    – Sridhar-Sarnobat
    Aug 3 '13 at 17:17




    But what if you have passwordless ssh? Can you do it then?
    – Sridhar-Sarnobat
    Aug 3 '13 at 17:17




    1




    1




    byobu is a nice, easier to use front end to screen (or tmux) - definitely worth a look (:
    – drevicko
    Feb 15 '15 at 22:35




    byobu is a nice, easier to use front end to screen (or tmux) - definitely worth a look (:
    – drevicko
    Feb 15 '15 at 22:35













    8














    For running long lasting processes, I use screen, or byobu if you want a more friendly interface.



    For screen, you can use:



    screen [program] [args]


    This will run [program] and its [args] inside a screen session. Once the program is finished, the session is automatically closed. If you wish to keep the session after your program runs, just run screen without any arguments and a new prompt will appear inside the session. CTRL+A+D detaches the terminal from the current session.



    To re-attach to a previous session:



    screen -r


    If there is only one session open, it will reattach immediately. If multiple sessions are ongoing, it will ask you which one you want to attach to. If you know the session name, you can just add it as an argument to this command line.



    Byobu is a nice improvement. It's based on screen, but provides a bar at the bottom that shows all current sessions as tabs and gives easier shortcuts to move around those. You can:




    • F2 start a new session

    • F3 move to the next session tab on the left

    • F4 move to the next session tab on the right

    • F8 give a friendly name to the current session tab

    • F9 opens a options menu

    • CTRL+A+D detaches all sessions from the terminal.


    WORD OF ADVICE: avoid leaving a session opened with the user root. If anyone gains access to your terminal (locally or remotely), they can easily re-attach to an ongoing session and use your system as root. If needed, it's best to start a session using a common user and sudo indivudual command lines as necessary.






    share|improve this answer

















    • 1




      May I quote the OP: "Moral of the story is to use screen a lot". Apparently that was not the question here.
      – January
      Sep 28 '12 at 12:13










    • Thanks for the writeup but January was correct.
      – user6658
      Sep 28 '12 at 16:53










    • Use sudo screen <command> to setup a screen as root, which needs sudo access to reconnect to it. Far better than starting a screen normally, then changing to root within it.
      – djsmiley2k
      Aug 15 '13 at 11:31
















    8














    For running long lasting processes, I use screen, or byobu if you want a more friendly interface.



    For screen, you can use:



    screen [program] [args]


    This will run [program] and its [args] inside a screen session. Once the program is finished, the session is automatically closed. If you wish to keep the session after your program runs, just run screen without any arguments and a new prompt will appear inside the session. CTRL+A+D detaches the terminal from the current session.



    To re-attach to a previous session:



    screen -r


    If there is only one session open, it will reattach immediately. If multiple sessions are ongoing, it will ask you which one you want to attach to. If you know the session name, you can just add it as an argument to this command line.



    Byobu is a nice improvement. It's based on screen, but provides a bar at the bottom that shows all current sessions as tabs and gives easier shortcuts to move around those. You can:




    • F2 start a new session

    • F3 move to the next session tab on the left

    • F4 move to the next session tab on the right

    • F8 give a friendly name to the current session tab

    • F9 opens a options menu

    • CTRL+A+D detaches all sessions from the terminal.


    WORD OF ADVICE: avoid leaving a session opened with the user root. If anyone gains access to your terminal (locally or remotely), they can easily re-attach to an ongoing session and use your system as root. If needed, it's best to start a session using a common user and sudo indivudual command lines as necessary.






    share|improve this answer

















    • 1




      May I quote the OP: "Moral of the story is to use screen a lot". Apparently that was not the question here.
      – January
      Sep 28 '12 at 12:13










    • Thanks for the writeup but January was correct.
      – user6658
      Sep 28 '12 at 16:53










    • Use sudo screen <command> to setup a screen as root, which needs sudo access to reconnect to it. Far better than starting a screen normally, then changing to root within it.
      – djsmiley2k
      Aug 15 '13 at 11:31














    8












    8








    8






    For running long lasting processes, I use screen, or byobu if you want a more friendly interface.



    For screen, you can use:



    screen [program] [args]


    This will run [program] and its [args] inside a screen session. Once the program is finished, the session is automatically closed. If you wish to keep the session after your program runs, just run screen without any arguments and a new prompt will appear inside the session. CTRL+A+D detaches the terminal from the current session.



    To re-attach to a previous session:



    screen -r


    If there is only one session open, it will reattach immediately. If multiple sessions are ongoing, it will ask you which one you want to attach to. If you know the session name, you can just add it as an argument to this command line.



    Byobu is a nice improvement. It's based on screen, but provides a bar at the bottom that shows all current sessions as tabs and gives easier shortcuts to move around those. You can:




    • F2 start a new session

    • F3 move to the next session tab on the left

    • F4 move to the next session tab on the right

    • F8 give a friendly name to the current session tab

    • F9 opens a options menu

    • CTRL+A+D detaches all sessions from the terminal.


    WORD OF ADVICE: avoid leaving a session opened with the user root. If anyone gains access to your terminal (locally or remotely), they can easily re-attach to an ongoing session and use your system as root. If needed, it's best to start a session using a common user and sudo indivudual command lines as necessary.






    share|improve this answer












    For running long lasting processes, I use screen, or byobu if you want a more friendly interface.



    For screen, you can use:



    screen [program] [args]


    This will run [program] and its [args] inside a screen session. Once the program is finished, the session is automatically closed. If you wish to keep the session after your program runs, just run screen without any arguments and a new prompt will appear inside the session. CTRL+A+D detaches the terminal from the current session.



    To re-attach to a previous session:



    screen -r


    If there is only one session open, it will reattach immediately. If multiple sessions are ongoing, it will ask you which one you want to attach to. If you know the session name, you can just add it as an argument to this command line.



    Byobu is a nice improvement. It's based on screen, but provides a bar at the bottom that shows all current sessions as tabs and gives easier shortcuts to move around those. You can:




    • F2 start a new session

    • F3 move to the next session tab on the left

    • F4 move to the next session tab on the right

    • F8 give a friendly name to the current session tab

    • F9 opens a options menu

    • CTRL+A+D detaches all sessions from the terminal.


    WORD OF ADVICE: avoid leaving a session opened with the user root. If anyone gains access to your terminal (locally or remotely), they can easily re-attach to an ongoing session and use your system as root. If needed, it's best to start a session using a common user and sudo indivudual command lines as necessary.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Sep 27 '12 at 21:44









    JulioHM

    466149




    466149








    • 1




      May I quote the OP: "Moral of the story is to use screen a lot". Apparently that was not the question here.
      – January
      Sep 28 '12 at 12:13










    • Thanks for the writeup but January was correct.
      – user6658
      Sep 28 '12 at 16:53










    • Use sudo screen <command> to setup a screen as root, which needs sudo access to reconnect to it. Far better than starting a screen normally, then changing to root within it.
      – djsmiley2k
      Aug 15 '13 at 11:31














    • 1




      May I quote the OP: "Moral of the story is to use screen a lot". Apparently that was not the question here.
      – January
      Sep 28 '12 at 12:13










    • Thanks for the writeup but January was correct.
      – user6658
      Sep 28 '12 at 16:53










    • Use sudo screen <command> to setup a screen as root, which needs sudo access to reconnect to it. Far better than starting a screen normally, then changing to root within it.
      – djsmiley2k
      Aug 15 '13 at 11:31








    1




    1




    May I quote the OP: "Moral of the story is to use screen a lot". Apparently that was not the question here.
    – January
    Sep 28 '12 at 12:13




    May I quote the OP: "Moral of the story is to use screen a lot". Apparently that was not the question here.
    – January
    Sep 28 '12 at 12:13












    Thanks for the writeup but January was correct.
    – user6658
    Sep 28 '12 at 16:53




    Thanks for the writeup but January was correct.
    – user6658
    Sep 28 '12 at 16:53












    Use sudo screen <command> to setup a screen as root, which needs sudo access to reconnect to it. Far better than starting a screen normally, then changing to root within it.
    – djsmiley2k
    Aug 15 '13 at 11:31




    Use sudo screen <command> to setup a screen as root, which needs sudo access to reconnect to it. Far better than starting a screen normally, then changing to root within it.
    – djsmiley2k
    Aug 15 '13 at 11:31











    5














    While you can't reattach to a broken SSH session, you can reparent the process running inside – functionally equivalent to what you want.



    In your case, you would take over the apt-get process to be controlled from a new SSH session, screen session or the like. My favourite for this is the reptyr command:



    $ sudo apt-get install reptyr
    $ ps ax | grep apt-get
    10626 pts/8 R+ 0:32 apt-get upgrade


    Then, with the pid you found for your process:



    $ reptyr 10626


    After this stage, all your keyboard input goes to the program you took over. Unfortunately you will not see old output of the SSH session, such as the apt-get output asking you for confirmation.



    There are multiple other tools that basically work the same as reptyr (that is, via ptrace debug attachment). See the following questions and answers where they are discussed:




    • How can I disown a running process and associate it to a new screen shell?

    • Resume command running in dropped SSH session


    (Details: The reason you can't take over a SSH session this way is because a sshd process is not controlled by a host terminal, instead it provides the slave part of a terminal – a pts device – while the master part controlling it resides on the client machine, here with a broken-down SSH session in between. When you force taking over such a sshd process with reptyr -s <pid>, your keyboard input goes to that process, not its active child process. So a "Ctrl+Z" will simply kill off that sshd.)






    share|improve this answer




























      5














      While you can't reattach to a broken SSH session, you can reparent the process running inside – functionally equivalent to what you want.



      In your case, you would take over the apt-get process to be controlled from a new SSH session, screen session or the like. My favourite for this is the reptyr command:



      $ sudo apt-get install reptyr
      $ ps ax | grep apt-get
      10626 pts/8 R+ 0:32 apt-get upgrade


      Then, with the pid you found for your process:



      $ reptyr 10626


      After this stage, all your keyboard input goes to the program you took over. Unfortunately you will not see old output of the SSH session, such as the apt-get output asking you for confirmation.



      There are multiple other tools that basically work the same as reptyr (that is, via ptrace debug attachment). See the following questions and answers where they are discussed:




      • How can I disown a running process and associate it to a new screen shell?

      • Resume command running in dropped SSH session


      (Details: The reason you can't take over a SSH session this way is because a sshd process is not controlled by a host terminal, instead it provides the slave part of a terminal – a pts device – while the master part controlling it resides on the client machine, here with a broken-down SSH session in between. When you force taking over such a sshd process with reptyr -s <pid>, your keyboard input goes to that process, not its active child process. So a "Ctrl+Z" will simply kill off that sshd.)






      share|improve this answer


























        5












        5








        5






        While you can't reattach to a broken SSH session, you can reparent the process running inside – functionally equivalent to what you want.



        In your case, you would take over the apt-get process to be controlled from a new SSH session, screen session or the like. My favourite for this is the reptyr command:



        $ sudo apt-get install reptyr
        $ ps ax | grep apt-get
        10626 pts/8 R+ 0:32 apt-get upgrade


        Then, with the pid you found for your process:



        $ reptyr 10626


        After this stage, all your keyboard input goes to the program you took over. Unfortunately you will not see old output of the SSH session, such as the apt-get output asking you for confirmation.



        There are multiple other tools that basically work the same as reptyr (that is, via ptrace debug attachment). See the following questions and answers where they are discussed:




        • How can I disown a running process and associate it to a new screen shell?

        • Resume command running in dropped SSH session


        (Details: The reason you can't take over a SSH session this way is because a sshd process is not controlled by a host terminal, instead it provides the slave part of a terminal – a pts device – while the master part controlling it resides on the client machine, here with a broken-down SSH session in between. When you force taking over such a sshd process with reptyr -s <pid>, your keyboard input goes to that process, not its active child process. So a "Ctrl+Z" will simply kill off that sshd.)






        share|improve this answer














        While you can't reattach to a broken SSH session, you can reparent the process running inside – functionally equivalent to what you want.



        In your case, you would take over the apt-get process to be controlled from a new SSH session, screen session or the like. My favourite for this is the reptyr command:



        $ sudo apt-get install reptyr
        $ ps ax | grep apt-get
        10626 pts/8 R+ 0:32 apt-get upgrade


        Then, with the pid you found for your process:



        $ reptyr 10626


        After this stage, all your keyboard input goes to the program you took over. Unfortunately you will not see old output of the SSH session, such as the apt-get output asking you for confirmation.



        There are multiple other tools that basically work the same as reptyr (that is, via ptrace debug attachment). See the following questions and answers where they are discussed:




        • How can I disown a running process and associate it to a new screen shell?

        • Resume command running in dropped SSH session


        (Details: The reason you can't take over a SSH session this way is because a sshd process is not controlled by a host terminal, instead it provides the slave part of a terminal – a pts device – while the master part controlling it resides on the client machine, here with a broken-down SSH session in between. When you force taking over such a sshd process with reptyr -s <pid>, your keyboard input goes to that process, not its active child process. So a "Ctrl+Z" will simply kill off that sshd.)







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 13 '17 at 12:37









        Community

        1




        1










        answered Feb 16 '17 at 14:12









        tanius

        2,4171822




        2,4171822






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • 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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2faskubuntu.com%2fquestions%2f191573%2fhow-can-i-reconnect-to-a-ssh-session-after-a-broken-pipe%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

            Mouse cursor on multiple screens with different PPI

            Agildo Ribeiro

            Sometime when accessing a menu: “Ubuntu 16.04 has experienced an internal error”