SSH Failing to fork with sshpass

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












4















I've a problem with port forwarding command using sshpass.
Problem is that it's working on one server and does not work on another.
Both are Debian 7 x64 boxes.



sshpass -p password ssh -f -D 0.0.0.0:2002 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=debug root@5.5.5.5 -T -N


This command works with no problems on server 1 but does not work on server 2.



Debug output from failing server:



Authenticated to 5.5.5.5 ([5.5.5.5]:22).
debug1: Local connections to 0.0.0.0:2002 forwarded to remote address socks:0
debug1: Local forwarding listening on 0.0.0.0 port 2002.
debug1: channel 0: new [port listener]
debug1: forking to background


Debug output from working server:



Authenticated to 5.5.5.5 ([5.5.5.5]:22).
debug1: Local connections to 0.0.0.0:2002 forwarded to remote address socks:0
debug1: Local forwarding listening on 0.0.0.0 port 2002.
debug1: channel 0: new [port listener]
debug1: forking to background
debug1: Entering interactive session.


Sshpass and ssh binaries are equal on both servers. I've checked this using md5sum.



Does anyone have an idea what could be wrong? I'm losing my mind trying to solve this mystery.










share|improve this question




























    4















    I've a problem with port forwarding command using sshpass.
    Problem is that it's working on one server and does not work on another.
    Both are Debian 7 x64 boxes.



    sshpass -p password ssh -f -D 0.0.0.0:2002 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=debug root@5.5.5.5 -T -N


    This command works with no problems on server 1 but does not work on server 2.



    Debug output from failing server:



    Authenticated to 5.5.5.5 ([5.5.5.5]:22).
    debug1: Local connections to 0.0.0.0:2002 forwarded to remote address socks:0
    debug1: Local forwarding listening on 0.0.0.0 port 2002.
    debug1: channel 0: new [port listener]
    debug1: forking to background


    Debug output from working server:



    Authenticated to 5.5.5.5 ([5.5.5.5]:22).
    debug1: Local connections to 0.0.0.0:2002 forwarded to remote address socks:0
    debug1: Local forwarding listening on 0.0.0.0 port 2002.
    debug1: channel 0: new [port listener]
    debug1: forking to background
    debug1: Entering interactive session.


    Sshpass and ssh binaries are equal on both servers. I've checked this using md5sum.



    Does anyone have an idea what could be wrong? I'm losing my mind trying to solve this mystery.










    share|improve this question


























      4












      4








      4


      1






      I've a problem with port forwarding command using sshpass.
      Problem is that it's working on one server and does not work on another.
      Both are Debian 7 x64 boxes.



      sshpass -p password ssh -f -D 0.0.0.0:2002 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=debug root@5.5.5.5 -T -N


      This command works with no problems on server 1 but does not work on server 2.



      Debug output from failing server:



      Authenticated to 5.5.5.5 ([5.5.5.5]:22).
      debug1: Local connections to 0.0.0.0:2002 forwarded to remote address socks:0
      debug1: Local forwarding listening on 0.0.0.0 port 2002.
      debug1: channel 0: new [port listener]
      debug1: forking to background


      Debug output from working server:



      Authenticated to 5.5.5.5 ([5.5.5.5]:22).
      debug1: Local connections to 0.0.0.0:2002 forwarded to remote address socks:0
      debug1: Local forwarding listening on 0.0.0.0 port 2002.
      debug1: channel 0: new [port listener]
      debug1: forking to background
      debug1: Entering interactive session.


      Sshpass and ssh binaries are equal on both servers. I've checked this using md5sum.



      Does anyone have an idea what could be wrong? I'm losing my mind trying to solve this mystery.










      share|improve this question
















      I've a problem with port forwarding command using sshpass.
      Problem is that it's working on one server and does not work on another.
      Both are Debian 7 x64 boxes.



      sshpass -p password ssh -f -D 0.0.0.0:2002 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=debug root@5.5.5.5 -T -N


      This command works with no problems on server 1 but does not work on server 2.



      Debug output from failing server:



      Authenticated to 5.5.5.5 ([5.5.5.5]:22).
      debug1: Local connections to 0.0.0.0:2002 forwarded to remote address socks:0
      debug1: Local forwarding listening on 0.0.0.0 port 2002.
      debug1: channel 0: new [port listener]
      debug1: forking to background


      Debug output from working server:



      Authenticated to 5.5.5.5 ([5.5.5.5]:22).
      debug1: Local connections to 0.0.0.0:2002 forwarded to remote address socks:0
      debug1: Local forwarding listening on 0.0.0.0 port 2002.
      debug1: channel 0: new [port listener]
      debug1: forking to background
      debug1: Entering interactive session.


      Sshpass and ssh binaries are equal on both servers. I've checked this using md5sum.



      Does anyone have an idea what could be wrong? I'm losing my mind trying to solve this mystery.







      debian ssh port-forwarding






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 13 '16 at 2:22









      Jeff Schaller

      41.7k1156133




      41.7k1156133










      asked Aug 9 '14 at 0:40









      MarkMark

      314




      314




















          1 Answer
          1






          active

          oldest

          votes


















          0














          TL;DR


          This worked for me:



          sshpass -p password nohup ssh -f ... >/dev/null




          Well, I almost lost my mind too.

          The difference between your debian hosts that causes sshpass to either work or not is the number of CPU cores. The issue appears on a single-core host. Playing with strace showed that sshpass process is killed by the system after receiving SIGHUP. On a multi-core host, the forked ssh process has enough time to setup SIGHUP handler so it's not killed.

          As a workaround you can use nohup utility to run sshpass so it's not killed by SIGHUP.






          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%2f149335%2fssh-failing-to-fork-with-sshpass%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            TL;DR


            This worked for me:



            sshpass -p password nohup ssh -f ... >/dev/null




            Well, I almost lost my mind too.

            The difference between your debian hosts that causes sshpass to either work or not is the number of CPU cores. The issue appears on a single-core host. Playing with strace showed that sshpass process is killed by the system after receiving SIGHUP. On a multi-core host, the forked ssh process has enough time to setup SIGHUP handler so it's not killed.

            As a workaround you can use nohup utility to run sshpass so it's not killed by SIGHUP.






            share|improve this answer





























              0














              TL;DR


              This worked for me:



              sshpass -p password nohup ssh -f ... >/dev/null




              Well, I almost lost my mind too.

              The difference between your debian hosts that causes sshpass to either work or not is the number of CPU cores. The issue appears on a single-core host. Playing with strace showed that sshpass process is killed by the system after receiving SIGHUP. On a multi-core host, the forked ssh process has enough time to setup SIGHUP handler so it's not killed.

              As a workaround you can use nohup utility to run sshpass so it's not killed by SIGHUP.






              share|improve this answer



























                0












                0








                0







                TL;DR


                This worked for me:



                sshpass -p password nohup ssh -f ... >/dev/null




                Well, I almost lost my mind too.

                The difference between your debian hosts that causes sshpass to either work or not is the number of CPU cores. The issue appears on a single-core host. Playing with strace showed that sshpass process is killed by the system after receiving SIGHUP. On a multi-core host, the forked ssh process has enough time to setup SIGHUP handler so it's not killed.

                As a workaround you can use nohup utility to run sshpass so it's not killed by SIGHUP.






                share|improve this answer















                TL;DR


                This worked for me:



                sshpass -p password nohup ssh -f ... >/dev/null




                Well, I almost lost my mind too.

                The difference between your debian hosts that causes sshpass to either work or not is the number of CPU cores. The issue appears on a single-core host. Playing with strace showed that sshpass process is killed by the system after receiving SIGHUP. On a multi-core host, the forked ssh process has enough time to setup SIGHUP handler so it's not killed.

                As a workaround you can use nohup utility to run sshpass so it's not killed by SIGHUP.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 26 '17 at 2:07

























                answered Nov 23 '17 at 4:34









                tifssofttifssoft

                51115




                51115



























                    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%2f149335%2fssh-failing-to-fork-with-sshpass%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

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?