5

I have computers A, B and C. Every one of them has ssh enabled and I can use rsync.

  • A can ssh to B
  • B can ssh to C
  • A can't ssh to C

B has public ssh access, so A can connect B and C can communicate because they are in a vpn and A is not part of it.

I would like to copy some files (and create a cronjob for this) from C to A.

What is a good way to do this?

UPDATE:

I was able to ssh to C via B as it was explained in the related answers that you suggest me but I was not able to rsync through serverB.

Consider that B is listening for ssh not on port 22.

αғsнιη
  • 41,407
res1
  • 278
  • 1
  • 3
  • 9

3 Answers3

5

This works for me:

rsync -avzhP -e "ssh -p portB -A user1@serverB ssh" user2@serverC:somedir/ localdir/

As reference I read this answer for a similar question:

https://stackoverflow.com/a/21787966/399637

αғsнιη
  • 41,407
res1
  • 278
  • 1
  • 3
  • 9
2

If host A can ssh into host B, and host B can ssh into host C, you can set up your ssh client configuration on host A to proxy through B to C. You can also tell rsync to use ssh as its transfer protocol (-e ssh). Combine these two things, and you can ssh or rsync from host A to C by way of B, even in a cron job.

DopeGhoti
  • 76,081
0

I used this command when the servers A, B and C don't have a port other than 22

rsync -azv -e 'ssh -A -J  UserServerB@AddressB' /file-in-ServerA UserServerC@AddresServerC:/path-ServerC

But if server B uses s port other than 22 to connect via ssh

rsync -azv -e 'ssh -A -J  UserServerB@AddressB:PortB' /file-in-ServerA UserServerC@AddresServerC:/path-ServerC