How is rsync able to work with ssh, when ssh reads and writes output of its own?

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











up vote
0
down vote

favorite












$ SSH_AUTH_SOCK= rsync x brick:
Enter passphrase for key '/home/alan/.ssh/id_rsa':
alan@brick.carrier.duckdns.org: Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.3]


rsync supports arbitrary remote shells with --rsh. How is the rsh, e.g. ssh, able to write messages, and not have them mis-interpreted as coming from the rsync process on the server?










share|improve this question

























    up vote
    0
    down vote

    favorite












    $ SSH_AUTH_SOCK= rsync x brick:
    Enter passphrase for key '/home/alan/.ssh/id_rsa':
    alan@brick.carrier.duckdns.org: Permission denied (publickey).
    rsync: connection unexpectedly closed (0 bytes received so far) [sender]
    rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.3]


    rsync supports arbitrary remote shells with --rsh. How is the rsh, e.g. ssh, able to write messages, and not have them mis-interpreted as coming from the rsync process on the server?










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      $ SSH_AUTH_SOCK= rsync x brick:
      Enter passphrase for key '/home/alan/.ssh/id_rsa':
      alan@brick.carrier.duckdns.org: Permission denied (publickey).
      rsync: connection unexpectedly closed (0 bytes received so far) [sender]
      rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.3]


      rsync supports arbitrary remote shells with --rsh. How is the rsh, e.g. ssh, able to write messages, and not have them mis-interpreted as coming from the rsync process on the server?










      share|improve this question













      $ SSH_AUTH_SOCK= rsync x brick:
      Enter passphrase for key '/home/alan/.ssh/id_rsa':
      alan@brick.carrier.duckdns.org: Permission denied (publickey).
      rsync: connection unexpectedly closed (0 bytes received so far) [sender]
      rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.3]


      rsync supports arbitrary remote shells with --rsh. How is the rsh, e.g. ssh, able to write messages, and not have them mis-interpreted as coming from the rsync process on the server?







      rsync






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 8 at 11:48









      sourcejedi

      19.9k42683




      19.9k42683




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          SSH is prompting and reading the login secrets through a separate file descriptor; it makes sure to open the current TTY.



          Most programs take care to read login secrets from a TTY, so that they can stop the password from being shown by temporarily disabling the "echo" on the TTY. I would expect them to make sure to write the prompt to the same TTY, for robustness sake.



          $ SSH_AUTH_SOCK= strace -f rsync x brick:
          ...
          [pid 26255] openat(AT_FDCWD, "/dev/tty", O_RDWR) = 4
          [pid 26255] ioctl(4, TCGETS, B38400 opost isig icanon echo ...) = 0
          [pid 26255] ioctl(4, SNDCTL_TMR_CONTINUE or TCSETSF, B38400 opost isig icanon -echo ...) = 0
          ...
          [pid 26255] write(4, "Enter passphrase for key '/home/"..., 51Enter passphrase for key '/home/alan/.ssh/id_rsa': ) = 51
          [pid 26255] read(4, "", 1) = 0
          [pid 26255] write(4, "n", 1
          ) = 1
          [pid 26255] ioctl(4, SNDCTL_TMR_CONTINUE or TCSETSF, B38400 opost isig icanon echo ...) = 0
          ...


          SSH printed the error message to standard error (open file number 2), not standard output (open file number 1) which rsync would use for its protocol.



          [pid 26255] write(2, "alan@brick.carrier.duckdns.org: "..., 64alan@brick.carrier.duckdns.org: Permission denied (publickey).
          ) = 64
          [pid 26255] exit_group(255) = ?





          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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f461268%2fhow-is-rsync-able-to-work-with-ssh-when-ssh-reads-and-writes-output-of-its-own%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote



            accepted










            SSH is prompting and reading the login secrets through a separate file descriptor; it makes sure to open the current TTY.



            Most programs take care to read login secrets from a TTY, so that they can stop the password from being shown by temporarily disabling the "echo" on the TTY. I would expect them to make sure to write the prompt to the same TTY, for robustness sake.



            $ SSH_AUTH_SOCK= strace -f rsync x brick:
            ...
            [pid 26255] openat(AT_FDCWD, "/dev/tty", O_RDWR) = 4
            [pid 26255] ioctl(4, TCGETS, B38400 opost isig icanon echo ...) = 0
            [pid 26255] ioctl(4, SNDCTL_TMR_CONTINUE or TCSETSF, B38400 opost isig icanon -echo ...) = 0
            ...
            [pid 26255] write(4, "Enter passphrase for key '/home/"..., 51Enter passphrase for key '/home/alan/.ssh/id_rsa': ) = 51
            [pid 26255] read(4, "", 1) = 0
            [pid 26255] write(4, "n", 1
            ) = 1
            [pid 26255] ioctl(4, SNDCTL_TMR_CONTINUE or TCSETSF, B38400 opost isig icanon echo ...) = 0
            ...


            SSH printed the error message to standard error (open file number 2), not standard output (open file number 1) which rsync would use for its protocol.



            [pid 26255] write(2, "alan@brick.carrier.duckdns.org: "..., 64alan@brick.carrier.duckdns.org: Permission denied (publickey).
            ) = 64
            [pid 26255] exit_group(255) = ?





            share|improve this answer
























              up vote
              0
              down vote



              accepted










              SSH is prompting and reading the login secrets through a separate file descriptor; it makes sure to open the current TTY.



              Most programs take care to read login secrets from a TTY, so that they can stop the password from being shown by temporarily disabling the "echo" on the TTY. I would expect them to make sure to write the prompt to the same TTY, for robustness sake.



              $ SSH_AUTH_SOCK= strace -f rsync x brick:
              ...
              [pid 26255] openat(AT_FDCWD, "/dev/tty", O_RDWR) = 4
              [pid 26255] ioctl(4, TCGETS, B38400 opost isig icanon echo ...) = 0
              [pid 26255] ioctl(4, SNDCTL_TMR_CONTINUE or TCSETSF, B38400 opost isig icanon -echo ...) = 0
              ...
              [pid 26255] write(4, "Enter passphrase for key '/home/"..., 51Enter passphrase for key '/home/alan/.ssh/id_rsa': ) = 51
              [pid 26255] read(4, "", 1) = 0
              [pid 26255] write(4, "n", 1
              ) = 1
              [pid 26255] ioctl(4, SNDCTL_TMR_CONTINUE or TCSETSF, B38400 opost isig icanon echo ...) = 0
              ...


              SSH printed the error message to standard error (open file number 2), not standard output (open file number 1) which rsync would use for its protocol.



              [pid 26255] write(2, "alan@brick.carrier.duckdns.org: "..., 64alan@brick.carrier.duckdns.org: Permission denied (publickey).
              ) = 64
              [pid 26255] exit_group(255) = ?





              share|improve this answer






















                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                SSH is prompting and reading the login secrets through a separate file descriptor; it makes sure to open the current TTY.



                Most programs take care to read login secrets from a TTY, so that they can stop the password from being shown by temporarily disabling the "echo" on the TTY. I would expect them to make sure to write the prompt to the same TTY, for robustness sake.



                $ SSH_AUTH_SOCK= strace -f rsync x brick:
                ...
                [pid 26255] openat(AT_FDCWD, "/dev/tty", O_RDWR) = 4
                [pid 26255] ioctl(4, TCGETS, B38400 opost isig icanon echo ...) = 0
                [pid 26255] ioctl(4, SNDCTL_TMR_CONTINUE or TCSETSF, B38400 opost isig icanon -echo ...) = 0
                ...
                [pid 26255] write(4, "Enter passphrase for key '/home/"..., 51Enter passphrase for key '/home/alan/.ssh/id_rsa': ) = 51
                [pid 26255] read(4, "", 1) = 0
                [pid 26255] write(4, "n", 1
                ) = 1
                [pid 26255] ioctl(4, SNDCTL_TMR_CONTINUE or TCSETSF, B38400 opost isig icanon echo ...) = 0
                ...


                SSH printed the error message to standard error (open file number 2), not standard output (open file number 1) which rsync would use for its protocol.



                [pid 26255] write(2, "alan@brick.carrier.duckdns.org: "..., 64alan@brick.carrier.duckdns.org: Permission denied (publickey).
                ) = 64
                [pid 26255] exit_group(255) = ?





                share|improve this answer












                SSH is prompting and reading the login secrets through a separate file descriptor; it makes sure to open the current TTY.



                Most programs take care to read login secrets from a TTY, so that they can stop the password from being shown by temporarily disabling the "echo" on the TTY. I would expect them to make sure to write the prompt to the same TTY, for robustness sake.



                $ SSH_AUTH_SOCK= strace -f rsync x brick:
                ...
                [pid 26255] openat(AT_FDCWD, "/dev/tty", O_RDWR) = 4
                [pid 26255] ioctl(4, TCGETS, B38400 opost isig icanon echo ...) = 0
                [pid 26255] ioctl(4, SNDCTL_TMR_CONTINUE or TCSETSF, B38400 opost isig icanon -echo ...) = 0
                ...
                [pid 26255] write(4, "Enter passphrase for key '/home/"..., 51Enter passphrase for key '/home/alan/.ssh/id_rsa': ) = 51
                [pid 26255] read(4, "", 1) = 0
                [pid 26255] write(4, "n", 1
                ) = 1
                [pid 26255] ioctl(4, SNDCTL_TMR_CONTINUE or TCSETSF, B38400 opost isig icanon echo ...) = 0
                ...


                SSH printed the error message to standard error (open file number 2), not standard output (open file number 1) which rsync would use for its protocol.



                [pid 26255] write(2, "alan@brick.carrier.duckdns.org: "..., 64alan@brick.carrier.duckdns.org: Permission denied (publickey).
                ) = 64
                [pid 26255] exit_group(255) = ?






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 8 at 11:48









                sourcejedi

                19.9k42683




                19.9k42683



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f461268%2fhow-is-rsync-able-to-work-with-ssh-when-ssh-reads-and-writes-output-of-its-own%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    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?