12

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?

20

Specify "myvps" as the hostname.

rsync /var/bar myvps:/home/foo ...
  • 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
  • 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
-1

@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

-1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.