How to use `~/.ssh/config` setting for each server by `rsync`












11















I'm now using rsync with -e 'ssh -p 10022' option to specify the port.



I have already ssh setting in ~/.ssh/config.



Host myvps
HostName example.com
User ironsand
Port 10022


Can I use this config from rsync easily?
Or Can I create ~/.rsync and set a default port for specify server?










share|improve this question





























    11















    I'm now using rsync with -e 'ssh -p 10022' option to specify the port.



    I have already ssh setting in ~/.ssh/config.



    Host myvps
    HostName example.com
    User ironsand
    Port 10022


    Can I use this config from rsync easily?
    Or Can I create ~/.rsync and set a default port for specify server?










    share|improve this question



























      11












      11








      11


      4






      I'm now using rsync with -e 'ssh -p 10022' option to specify the port.



      I have already ssh setting in ~/.ssh/config.



      Host myvps
      HostName example.com
      User ironsand
      Port 10022


      Can I use this config from rsync easily?
      Or Can I create ~/.rsync and set a default port for specify server?










      share|improve this question
















      I'm now using rsync with -e 'ssh -p 10022' option to specify the port.



      I have already ssh setting in ~/.ssh/config.



      Host myvps
      HostName example.com
      User ironsand
      Port 10022


      Can I use this config from rsync easily?
      Or Can I create ~/.rsync and set a default port for specify server?







      ssh rsync






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 10 '13 at 21:05









      Gilles

      543k12811011618




      543k12811011618










      asked Oct 10 '13 at 11:27









      ironsandironsand

      1,60562452




      1,60562452






















          5 Answers
          5






          active

          oldest

          votes


















          18














          Specify "myvps" as the hostname.



          rsync /var/bar myvps:/home/foo ...





          share|improve this answer
























          • doing rsync from user home dir where ssh config is kept, worked for me, even it supports node hoping.

            – Stalin Gino
            Nov 2 '18 at 6:29



















          8














          This did not work for me. I have jump hosting in my ~/.ssh/config



          Host 10.x.y.z
          User cloud-user
          HostName vm-pivot
          IdentityFile /path_to_vm_key

          Host 21ct-dev1-*
          User cloud-user
          HostName %h.example.com
          ProxyCommand ssh 10.x.y.z -W %h:%p
          IdentityFile /path_to_vm_key


          rsync -e "ssh" local_path vm-app01:/remote_path


          ssh: Could not resolve hostname vm-app01: nodename nor servname provided, or not known
          rsync: connection unexpectedly closed (0 bytes received so far) [sender]
          rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]



          However, this works just fine



          [kbroughton@kbroughton:project + (develop)] ssh vm-app01
          Last login: Thu Apr 17 12:10:37 2014 from 10.a.b.c


          Edit, I was able to get past the name resolution by forcing rsync ssh to load a config file with -F
          sudo rsync -az -e "ssh -F /Users/kbroughton/.ssh/config"



          This gets past one error but onto another.
          Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
          ssh_exchange_identification: Connection closed by remote host



          Also tried explicitly setting -i and user@ in the connection but same error occurs.



          EDIT



          Another data point. If i use the floating ip of the pivot vm (jump host) instead of its name vm-pivot rsync works. But explicitly dumping all my ssh/config in the -e "ssh" does not work. Details: local mac, upgraded to rsync 3.1.0, remote centos rsync 3.0.9.



          [kbroughton@kbroughton:project + (develop)] sudo /usr/local/bin/rsync -az -e "ssh -F /Users/kbroughton/.ssh/config -i /Users/kbroughton/.ssh/identities/vm_key -W 10.x.y.z:22"  /var/data/sources/data.tar.gz user@vm-pivot:/home/user

          Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
          ssh_exchange_identification: Connection closed by remote host
          rsync: connection unexpectedly closed (0 bytes received so far) [sender]
          rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.0]

          [kbroughton@kbroughton:project + (develop)] sudo /usr/local/bin/rsync -az -e "ssh -F /Users/kbroughton/.ssh/config -i /Users/kbroughton/.ssh/identities/vm_key -W 10.x.y.z:22" /var/data/sources/data.tar.gz user@10.x.y.z:/home/user
          protocol version mismatch -- is your shell clean?
          (see the rsync man page for an explanation)
          rsync error: protocol incompatibility (code 2) at compat.c(181) [sender=3.1.0]


          This works



          [kbroughton@kbroughton:project + (develop)] sudo /usr/local/bin/rsync -az -e "ssh -F /Users/kbroughton/.ssh/config -i /Users/kbroughton/.ssh/identities/vm_key"  /var/data/sources/data.tar.gz user@10.x.y.z:/home/user





          share|improve this answer


























          • I realized that in my case I could not use the shortcut, but actual full host name could be used

            – dashesy
            Jun 25 '14 at 2:37



















          1














          @darKoram. For cases where you invoke ssh with non-standard path and try use ssh in ProxyCommand that is problem because there no inheritance. You have two option there: direct provide same file in inner command, or dynamically hack it.
          You may look detailed description in my blog post about that: http://hubbitus.info/wiki/Blog:Ssh_forwarding_with_same_config_file_hack



          Shortly in you situation should help configuration like:



          Host 21ct-dev1-*
          User cloud-user
          HostName %h.example.com
          ProxyCommand ssh $( egrep -z -A1 '^-F$' /proc/$PPID/cmdline ) 10.x.y.z -W %h:%p
          IdentityFile /path_to_vm_key





          share|improve this answer































            0














            @darKoram. Run the SSH process with sudo:



            sudo /usr/local/bin/rsync -az -e "sudo -u user ssh" /var/data/sources/data.tar.gz vm-app01:/home/user






            share|improve this answer































              0














              @darKoram



              What is the full DNS name of "vm-app01"? It must be public, since you claim you could reach it within ssh without rsync. But, you expect ssh to catch your host via the pattern "21ct-dev1-*". I really cant see how this could work in any way. If you try to pattern hostnames, it should look something like this:



              Host *.21ct-dev1-domain.tld


              Then the call of rsync should then look something like this:



              rsync -e "ssh" /local/path/ vm-app01.21ct-dev1-domain.tld:/remote/path/


              How is "vm-app01" resolved? Hosts file, wins, nis, nss? Do you have an alias? Are you within a domain? It certainly looks like a "simple" DNS problem.






              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%2f94421%2fhow-to-use-ssh-config-setting-for-each-server-by-rsync%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                5 Answers
                5






                active

                oldest

                votes








                5 Answers
                5






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                18














                Specify "myvps" as the hostname.



                rsync /var/bar myvps:/home/foo ...





                share|improve this answer
























                • doing rsync from user home dir where ssh config is kept, worked for me, even it supports node hoping.

                  – Stalin Gino
                  Nov 2 '18 at 6:29
















                18














                Specify "myvps" as the hostname.



                rsync /var/bar myvps:/home/foo ...





                share|improve this answer
























                • doing rsync from user home dir where ssh config is kept, worked for me, even it supports node hoping.

                  – Stalin Gino
                  Nov 2 '18 at 6:29














                18












                18








                18







                Specify "myvps" as the hostname.



                rsync /var/bar myvps:/home/foo ...





                share|improve this answer













                Specify "myvps" as the hostname.



                rsync /var/bar myvps:/home/foo ...






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Oct 10 '13 at 11:42









                Ignacio Vazquez-AbramsIgnacio Vazquez-Abrams

                33.6k66982




                33.6k66982













                • doing rsync from user home dir where ssh config is kept, worked for me, even it supports node hoping.

                  – Stalin Gino
                  Nov 2 '18 at 6:29



















                • doing rsync from user home dir where ssh config is kept, worked for me, even it supports node hoping.

                  – Stalin Gino
                  Nov 2 '18 at 6:29

















                doing rsync from user home dir where ssh config is kept, worked for me, even it supports node hoping.

                – Stalin Gino
                Nov 2 '18 at 6:29





                doing rsync from user home dir where ssh config is kept, worked for me, even it supports node hoping.

                – Stalin Gino
                Nov 2 '18 at 6:29













                8














                This did not work for me. I have jump hosting in my ~/.ssh/config



                Host 10.x.y.z
                User cloud-user
                HostName vm-pivot
                IdentityFile /path_to_vm_key

                Host 21ct-dev1-*
                User cloud-user
                HostName %h.example.com
                ProxyCommand ssh 10.x.y.z -W %h:%p
                IdentityFile /path_to_vm_key


                rsync -e "ssh" local_path vm-app01:/remote_path


                ssh: Could not resolve hostname vm-app01: nodename nor servname provided, or not known
                rsync: connection unexpectedly closed (0 bytes received so far) [sender]
                rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]



                However, this works just fine



                [kbroughton@kbroughton:project + (develop)] ssh vm-app01
                Last login: Thu Apr 17 12:10:37 2014 from 10.a.b.c


                Edit, I was able to get past the name resolution by forcing rsync ssh to load a config file with -F
                sudo rsync -az -e "ssh -F /Users/kbroughton/.ssh/config"



                This gets past one error but onto another.
                Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
                ssh_exchange_identification: Connection closed by remote host



                Also tried explicitly setting -i and user@ in the connection but same error occurs.



                EDIT



                Another data point. If i use the floating ip of the pivot vm (jump host) instead of its name vm-pivot rsync works. But explicitly dumping all my ssh/config in the -e "ssh" does not work. Details: local mac, upgraded to rsync 3.1.0, remote centos rsync 3.0.9.



                [kbroughton@kbroughton:project + (develop)] sudo /usr/local/bin/rsync -az -e "ssh -F /Users/kbroughton/.ssh/config -i /Users/kbroughton/.ssh/identities/vm_key -W 10.x.y.z:22"  /var/data/sources/data.tar.gz user@vm-pivot:/home/user

                Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
                ssh_exchange_identification: Connection closed by remote host
                rsync: connection unexpectedly closed (0 bytes received so far) [sender]
                rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.0]

                [kbroughton@kbroughton:project + (develop)] sudo /usr/local/bin/rsync -az -e "ssh -F /Users/kbroughton/.ssh/config -i /Users/kbroughton/.ssh/identities/vm_key -W 10.x.y.z:22" /var/data/sources/data.tar.gz user@10.x.y.z:/home/user
                protocol version mismatch -- is your shell clean?
                (see the rsync man page for an explanation)
                rsync error: protocol incompatibility (code 2) at compat.c(181) [sender=3.1.0]


                This works



                [kbroughton@kbroughton:project + (develop)] sudo /usr/local/bin/rsync -az -e "ssh -F /Users/kbroughton/.ssh/config -i /Users/kbroughton/.ssh/identities/vm_key"  /var/data/sources/data.tar.gz user@10.x.y.z:/home/user





                share|improve this answer


























                • I realized that in my case I could not use the shortcut, but actual full host name could be used

                  – dashesy
                  Jun 25 '14 at 2:37
















                8














                This did not work for me. I have jump hosting in my ~/.ssh/config



                Host 10.x.y.z
                User cloud-user
                HostName vm-pivot
                IdentityFile /path_to_vm_key

                Host 21ct-dev1-*
                User cloud-user
                HostName %h.example.com
                ProxyCommand ssh 10.x.y.z -W %h:%p
                IdentityFile /path_to_vm_key


                rsync -e "ssh" local_path vm-app01:/remote_path


                ssh: Could not resolve hostname vm-app01: nodename nor servname provided, or not known
                rsync: connection unexpectedly closed (0 bytes received so far) [sender]
                rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]



                However, this works just fine



                [kbroughton@kbroughton:project + (develop)] ssh vm-app01
                Last login: Thu Apr 17 12:10:37 2014 from 10.a.b.c


                Edit, I was able to get past the name resolution by forcing rsync ssh to load a config file with -F
                sudo rsync -az -e "ssh -F /Users/kbroughton/.ssh/config"



                This gets past one error but onto another.
                Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
                ssh_exchange_identification: Connection closed by remote host



                Also tried explicitly setting -i and user@ in the connection but same error occurs.



                EDIT



                Another data point. If i use the floating ip of the pivot vm (jump host) instead of its name vm-pivot rsync works. But explicitly dumping all my ssh/config in the -e "ssh" does not work. Details: local mac, upgraded to rsync 3.1.0, remote centos rsync 3.0.9.



                [kbroughton@kbroughton:project + (develop)] sudo /usr/local/bin/rsync -az -e "ssh -F /Users/kbroughton/.ssh/config -i /Users/kbroughton/.ssh/identities/vm_key -W 10.x.y.z:22"  /var/data/sources/data.tar.gz user@vm-pivot:/home/user

                Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
                ssh_exchange_identification: Connection closed by remote host
                rsync: connection unexpectedly closed (0 bytes received so far) [sender]
                rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.0]

                [kbroughton@kbroughton:project + (develop)] sudo /usr/local/bin/rsync -az -e "ssh -F /Users/kbroughton/.ssh/config -i /Users/kbroughton/.ssh/identities/vm_key -W 10.x.y.z:22" /var/data/sources/data.tar.gz user@10.x.y.z:/home/user
                protocol version mismatch -- is your shell clean?
                (see the rsync man page for an explanation)
                rsync error: protocol incompatibility (code 2) at compat.c(181) [sender=3.1.0]


                This works



                [kbroughton@kbroughton:project + (develop)] sudo /usr/local/bin/rsync -az -e "ssh -F /Users/kbroughton/.ssh/config -i /Users/kbroughton/.ssh/identities/vm_key"  /var/data/sources/data.tar.gz user@10.x.y.z:/home/user





                share|improve this answer


























                • I realized that in my case I could not use the shortcut, but actual full host name could be used

                  – dashesy
                  Jun 25 '14 at 2:37














                8












                8








                8







                This did not work for me. I have jump hosting in my ~/.ssh/config



                Host 10.x.y.z
                User cloud-user
                HostName vm-pivot
                IdentityFile /path_to_vm_key

                Host 21ct-dev1-*
                User cloud-user
                HostName %h.example.com
                ProxyCommand ssh 10.x.y.z -W %h:%p
                IdentityFile /path_to_vm_key


                rsync -e "ssh" local_path vm-app01:/remote_path


                ssh: Could not resolve hostname vm-app01: nodename nor servname provided, or not known
                rsync: connection unexpectedly closed (0 bytes received so far) [sender]
                rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]



                However, this works just fine



                [kbroughton@kbroughton:project + (develop)] ssh vm-app01
                Last login: Thu Apr 17 12:10:37 2014 from 10.a.b.c


                Edit, I was able to get past the name resolution by forcing rsync ssh to load a config file with -F
                sudo rsync -az -e "ssh -F /Users/kbroughton/.ssh/config"



                This gets past one error but onto another.
                Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
                ssh_exchange_identification: Connection closed by remote host



                Also tried explicitly setting -i and user@ in the connection but same error occurs.



                EDIT



                Another data point. If i use the floating ip of the pivot vm (jump host) instead of its name vm-pivot rsync works. But explicitly dumping all my ssh/config in the -e "ssh" does not work. Details: local mac, upgraded to rsync 3.1.0, remote centos rsync 3.0.9.



                [kbroughton@kbroughton:project + (develop)] sudo /usr/local/bin/rsync -az -e "ssh -F /Users/kbroughton/.ssh/config -i /Users/kbroughton/.ssh/identities/vm_key -W 10.x.y.z:22"  /var/data/sources/data.tar.gz user@vm-pivot:/home/user

                Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
                ssh_exchange_identification: Connection closed by remote host
                rsync: connection unexpectedly closed (0 bytes received so far) [sender]
                rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.0]

                [kbroughton@kbroughton:project + (develop)] sudo /usr/local/bin/rsync -az -e "ssh -F /Users/kbroughton/.ssh/config -i /Users/kbroughton/.ssh/identities/vm_key -W 10.x.y.z:22" /var/data/sources/data.tar.gz user@10.x.y.z:/home/user
                protocol version mismatch -- is your shell clean?
                (see the rsync man page for an explanation)
                rsync error: protocol incompatibility (code 2) at compat.c(181) [sender=3.1.0]


                This works



                [kbroughton@kbroughton:project + (develop)] sudo /usr/local/bin/rsync -az -e "ssh -F /Users/kbroughton/.ssh/config -i /Users/kbroughton/.ssh/identities/vm_key"  /var/data/sources/data.tar.gz user@10.x.y.z:/home/user





                share|improve this answer















                This did not work for me. I have jump hosting in my ~/.ssh/config



                Host 10.x.y.z
                User cloud-user
                HostName vm-pivot
                IdentityFile /path_to_vm_key

                Host 21ct-dev1-*
                User cloud-user
                HostName %h.example.com
                ProxyCommand ssh 10.x.y.z -W %h:%p
                IdentityFile /path_to_vm_key


                rsync -e "ssh" local_path vm-app01:/remote_path


                ssh: Could not resolve hostname vm-app01: nodename nor servname provided, or not known
                rsync: connection unexpectedly closed (0 bytes received so far) [sender]
                rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]



                However, this works just fine



                [kbroughton@kbroughton:project + (develop)] ssh vm-app01
                Last login: Thu Apr 17 12:10:37 2014 from 10.a.b.c


                Edit, I was able to get past the name resolution by forcing rsync ssh to load a config file with -F
                sudo rsync -az -e "ssh -F /Users/kbroughton/.ssh/config"



                This gets past one error but onto another.
                Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
                ssh_exchange_identification: Connection closed by remote host



                Also tried explicitly setting -i and user@ in the connection but same error occurs.



                EDIT



                Another data point. If i use the floating ip of the pivot vm (jump host) instead of its name vm-pivot rsync works. But explicitly dumping all my ssh/config in the -e "ssh" does not work. Details: local mac, upgraded to rsync 3.1.0, remote centos rsync 3.0.9.



                [kbroughton@kbroughton:project + (develop)] sudo /usr/local/bin/rsync -az -e "ssh -F /Users/kbroughton/.ssh/config -i /Users/kbroughton/.ssh/identities/vm_key -W 10.x.y.z:22"  /var/data/sources/data.tar.gz user@vm-pivot:/home/user

                Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
                ssh_exchange_identification: Connection closed by remote host
                rsync: connection unexpectedly closed (0 bytes received so far) [sender]
                rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.0]

                [kbroughton@kbroughton:project + (develop)] sudo /usr/local/bin/rsync -az -e "ssh -F /Users/kbroughton/.ssh/config -i /Users/kbroughton/.ssh/identities/vm_key -W 10.x.y.z:22" /var/data/sources/data.tar.gz user@10.x.y.z:/home/user
                protocol version mismatch -- is your shell clean?
                (see the rsync man page for an explanation)
                rsync error: protocol incompatibility (code 2) at compat.c(181) [sender=3.1.0]


                This works



                [kbroughton@kbroughton:project + (develop)] sudo /usr/local/bin/rsync -az -e "ssh -F /Users/kbroughton/.ssh/config -i /Users/kbroughton/.ssh/identities/vm_key"  /var/data/sources/data.tar.gz user@10.x.y.z:/home/user






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 19 '14 at 14:55

























                answered Apr 17 '14 at 16:18









                darKoramdarKoram

                18114




                18114













                • I realized that in my case I could not use the shortcut, but actual full host name could be used

                  – dashesy
                  Jun 25 '14 at 2:37



















                • I realized that in my case I could not use the shortcut, but actual full host name could be used

                  – dashesy
                  Jun 25 '14 at 2:37

















                I realized that in my case I could not use the shortcut, but actual full host name could be used

                – dashesy
                Jun 25 '14 at 2:37





                I realized that in my case I could not use the shortcut, but actual full host name could be used

                – dashesy
                Jun 25 '14 at 2:37











                1














                @darKoram. For cases where you invoke ssh with non-standard path and try use ssh in ProxyCommand that is problem because there no inheritance. You have two option there: direct provide same file in inner command, or dynamically hack it.
                You may look detailed description in my blog post about that: http://hubbitus.info/wiki/Blog:Ssh_forwarding_with_same_config_file_hack



                Shortly in you situation should help configuration like:



                Host 21ct-dev1-*
                User cloud-user
                HostName %h.example.com
                ProxyCommand ssh $( egrep -z -A1 '^-F$' /proc/$PPID/cmdline ) 10.x.y.z -W %h:%p
                IdentityFile /path_to_vm_key





                share|improve this answer




























                  1














                  @darKoram. For cases where you invoke ssh with non-standard path and try use ssh in ProxyCommand that is problem because there no inheritance. You have two option there: direct provide same file in inner command, or dynamically hack it.
                  You may look detailed description in my blog post about that: http://hubbitus.info/wiki/Blog:Ssh_forwarding_with_same_config_file_hack



                  Shortly in you situation should help configuration like:



                  Host 21ct-dev1-*
                  User cloud-user
                  HostName %h.example.com
                  ProxyCommand ssh $( egrep -z -A1 '^-F$' /proc/$PPID/cmdline ) 10.x.y.z -W %h:%p
                  IdentityFile /path_to_vm_key





                  share|improve this answer


























                    1












                    1








                    1







                    @darKoram. For cases where you invoke ssh with non-standard path and try use ssh in ProxyCommand that is problem because there no inheritance. You have two option there: direct provide same file in inner command, or dynamically hack it.
                    You may look detailed description in my blog post about that: http://hubbitus.info/wiki/Blog:Ssh_forwarding_with_same_config_file_hack



                    Shortly in you situation should help configuration like:



                    Host 21ct-dev1-*
                    User cloud-user
                    HostName %h.example.com
                    ProxyCommand ssh $( egrep -z -A1 '^-F$' /proc/$PPID/cmdline ) 10.x.y.z -W %h:%p
                    IdentityFile /path_to_vm_key





                    share|improve this answer













                    @darKoram. For cases where you invoke ssh with non-standard path and try use ssh in ProxyCommand that is problem because there no inheritance. You have two option there: direct provide same file in inner command, or dynamically hack it.
                    You may look detailed description in my blog post about that: http://hubbitus.info/wiki/Blog:Ssh_forwarding_with_same_config_file_hack



                    Shortly in you situation should help configuration like:



                    Host 21ct-dev1-*
                    User cloud-user
                    HostName %h.example.com
                    ProxyCommand ssh $( egrep -z -A1 '^-F$' /proc/$PPID/cmdline ) 10.x.y.z -W %h:%p
                    IdentityFile /path_to_vm_key






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Aug 5 '15 at 11:16









                    HubbitusHubbitus

                    1314




                    1314























                        0














                        @darKoram. Run the SSH process with sudo:



                        sudo /usr/local/bin/rsync -az -e "sudo -u user ssh" /var/data/sources/data.tar.gz vm-app01:/home/user






                        share|improve this answer




























                          0














                          @darKoram. Run the SSH process with sudo:



                          sudo /usr/local/bin/rsync -az -e "sudo -u user ssh" /var/data/sources/data.tar.gz vm-app01:/home/user






                          share|improve this answer


























                            0












                            0








                            0







                            @darKoram. Run the SSH process with sudo:



                            sudo /usr/local/bin/rsync -az -e "sudo -u user ssh" /var/data/sources/data.tar.gz vm-app01:/home/user






                            share|improve this answer













                            @darKoram. Run the SSH process with sudo:



                            sudo /usr/local/bin/rsync -az -e "sudo -u user ssh" /var/data/sources/data.tar.gz vm-app01:/home/user







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jun 14 '18 at 22:26









                            GreywoodGreywood

                            1




                            1























                                0














                                @darKoram



                                What is the full DNS name of "vm-app01"? It must be public, since you claim you could reach it within ssh without rsync. But, you expect ssh to catch your host via the pattern "21ct-dev1-*". I really cant see how this could work in any way. If you try to pattern hostnames, it should look something like this:



                                Host *.21ct-dev1-domain.tld


                                Then the call of rsync should then look something like this:



                                rsync -e "ssh" /local/path/ vm-app01.21ct-dev1-domain.tld:/remote/path/


                                How is "vm-app01" resolved? Hosts file, wins, nis, nss? Do you have an alias? Are you within a domain? It certainly looks like a "simple" DNS problem.






                                share|improve this answer




























                                  0














                                  @darKoram



                                  What is the full DNS name of "vm-app01"? It must be public, since you claim you could reach it within ssh without rsync. But, you expect ssh to catch your host via the pattern "21ct-dev1-*". I really cant see how this could work in any way. If you try to pattern hostnames, it should look something like this:



                                  Host *.21ct-dev1-domain.tld


                                  Then the call of rsync should then look something like this:



                                  rsync -e "ssh" /local/path/ vm-app01.21ct-dev1-domain.tld:/remote/path/


                                  How is "vm-app01" resolved? Hosts file, wins, nis, nss? Do you have an alias? Are you within a domain? It certainly looks like a "simple" DNS problem.






                                  share|improve this answer


























                                    0












                                    0








                                    0







                                    @darKoram



                                    What is the full DNS name of "vm-app01"? It must be public, since you claim you could reach it within ssh without rsync. But, you expect ssh to catch your host via the pattern "21ct-dev1-*". I really cant see how this could work in any way. If you try to pattern hostnames, it should look something like this:



                                    Host *.21ct-dev1-domain.tld


                                    Then the call of rsync should then look something like this:



                                    rsync -e "ssh" /local/path/ vm-app01.21ct-dev1-domain.tld:/remote/path/


                                    How is "vm-app01" resolved? Hosts file, wins, nis, nss? Do you have an alias? Are you within a domain? It certainly looks like a "simple" DNS problem.






                                    share|improve this answer













                                    @darKoram



                                    What is the full DNS name of "vm-app01"? It must be public, since you claim you could reach it within ssh without rsync. But, you expect ssh to catch your host via the pattern "21ct-dev1-*". I really cant see how this could work in any way. If you try to pattern hostnames, it should look something like this:



                                    Host *.21ct-dev1-domain.tld


                                    Then the call of rsync should then look something like this:



                                    rsync -e "ssh" /local/path/ vm-app01.21ct-dev1-domain.tld:/remote/path/


                                    How is "vm-app01" resolved? Hosts file, wins, nis, nss? Do you have an alias? Are you within a domain? It certainly looks like a "simple" DNS problem.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered 27 mins ago









                                    WGRMWGRM

                                    1




                                    1






























                                        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%2f94421%2fhow-to-use-ssh-config-setting-for-each-server-by-rsync%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

                                        Accessing regular linux commands in Huawei's Dopra Linux

                                        Can't connect RFCOMM socket: Host is down

                                        Kernel panic - not syncing: Fatal Exception in Interrupt