# Rsync through router without router config

## grant123

Can I rsync to a system that is behind a router without configuring the router?  Maybe if I have the system I want to rsync to make itself available to me somehow?

----------

## Hu

You can use as an rsync server any machine to which you can connect over an rsync transport.  Typical consumer routers will by default drop connection requests coming from the Internet.

----------

## grant123

I'm giving a laptop to a non-technical person and I want to be able to rsync to it periodically.  I could try to explain to them how to configure their router but I'm wondering if there is a way around that.  Any creative solutions?  Can I have the laptop connect to a server on the internet which will hand off the rsync connection for me?

----------

## UberLord

Sounds like you need a VPN.open VPN is quite good for this.

----------

## grant123

Thanks Uberlord.  It seems like OpenVPN would be a lot of trouble for this.  Any other options?

----------

## UberLord

OpenVPN is quite easy to configure at both ends. And is pretty much guaranteed to work.

Of course, you could employ another brand of VPN.

The other option, as you say, is configuring their router.

This has it's own set of problems

  *  Can the router port forward to start with?

  *  What if someone else wants the port (a rsync server belongs to spouse?)

  *  Do it again when router is swapped out

  *  Do it again if laptop moves out

  *  Laptop could be on business trips a lot - i don't know if you need to rsync at these times.

I'm sure there are more reasons, but frankly installing some kind of VPN end point is your best option for less hassle later.

----------

## Ant P.

IPv6 would be a good option - but if you're stuck with the kind of router that causes this problem, it probably doesn't support that at all.

----------

## UberLord

 *Ant P. wrote:*   

> IPv6 would be a good option

 

I didn't mention that because there's no guarantee the laptop will be used in an IPv6 environment.

In the UK at least you have to goto a small ISP to get IPv6 as none of the big ones offer it.

----------

## krinn

you may also just tunnel rsync with ssh, and then just need a valid ssh access already set behind your router.

----------

## steveL

Yeah rsync over ssh is lovely; we use it on the LAN as well, in addition to ssh-fs for things like distfiles.

#openssh is the best place to get incisive advice from professionals using it, ime.

Though you'd also get a good deal of help on rsync in #bash

Both on IRC: chat.freenode.net or .org

----------

## UberLord

Surely rsync over ssh tunnel requires the *same* router modifications as the rsync straight to the laptop - the router needs to port forward to the laptop.

The problems with this approach I listed above and still apply.

Unless I'm missing something mind-numbingly obvious...

----------

## grant123

Could I have the laptop automatically connect to my server via SSH after prompting the desktop user for credentials?  Then the SSH connection would be up all the time and I could rsync to the laptop that way.

----------

## szatox

 *Quote:*   

> Can I rsync to a system that is behind a router without configuring the router? Maybe if I have the system I want to rsync to make itself available to me somehow

 

Does the direction (to a system behind a router - with a NAT by default) refer to data transfer or initiating a session?

If it's the latter, it can be done, but it's tricky. As already said, it requires port redirection and you basically don't want to do that with any router you don't hold with your hand (so you need a vpn)

If it's the former... Yes, you can. Just open the session from behind the NAT and pull the data. Most likely you will not even notice that NAT on your way.

----------

## UberLord

 *grant123 wrote:*   

> Could I have the laptop automatically connect to my server via SSH after prompting the desktop user for credentials?  Then the SSH connection would be up all the time and I could rsync to the laptop that way.

 

If you can do that, just get the laptop to rsync push or pull to you.

This avoids ssh which would prompt for a passord.

This avoids any router or VPN changes.

This could also be put into a cron job to happen at set times.

----------

## steveL

 *UberLord wrote:*   

> Surely rsync over ssh tunnel requires the *same* router modifications as the rsync straight to the laptop - the router needs to port forward to the laptop.

 

Makes sense.

 *Quote:*   

> The problems with this approach I listed above and still apply.
> 
> Unless I'm missing something mind-numbingly obvious...

 

Nah, I wasn't really paying attention to the topic, my bad; I just noticed krinn's nick and the bit about rsync over ssh, and wanted to add a vote of confidence.

Though ssh is often set-up already, as krinn pointed out. If not, it's one of the first things you want to set up, and thereafter rsync (or anything else, including X) isn't such an issue.

----------

## grant123

The way my maintenance script works, I need to be able to rsync push to the laptop.  Can I have SSH automatically connect so I can rsync push through that connection to the laptop, but for security not give the laptop a real shell on the system it's connecting to?

----------

## 1clue

You could add a point for your rsync, so there's something outside the firewall.  Something that works like dropbox.com.

----------

## grant123

1clue, yes, what is available like that?

----------

## 1clue

you could use any cloud storage and rsync, or you could use dropbox.  Dropbox for Linux is basically a web page, not sure I'd recommend that for what you're talking about.

You could also go get a minimal box on linode.com for example, and do a true rsync since that's a linux box.

Sorry I don't have a lot of solutions for you, I've never needed to do this sort of  thing.

Come to think of it though, what sort of files are you talking about?  Have you considered a git repository?

Personally my solution would be to install that vpn.  You didn't like that, I'm just trying to figure out something else that might work.

Disclaimer: I am very suspicious of cloud storage, especially any service you get for free.  If you get a service for free on the Internet, you are not the customer.  You're the product.

----------

## krinn

 *UberLord wrote:*   

> If you can do that, just get the laptop to rsync push or pull to you.
> 
> This avoids ssh which would prompt for a passord.

 

you can setup a passwordless ssh access, it's his laptop, he can easy create and known the public key to use for that, and setup all accesses need for that.

ssh offer more flexibility, as you can do a cron job with ssh querying if any action should be done or not by checking files presence (just like fsck do with /fastboot)

#/bin/bash

cmd=$(ssh user@desktop ls /tmp/runwithssh-*)

// and a list of if cmd == runwithssh-rsync -> rsync or runwithssh-reboot -> shutdown -r 1...

now you can check what files are there and execute the wanted commands from the laptop, allowing the desktop to instruct the laptop to do prebuild commands without accessing it as it's the laptop that access the desktop (and no router issue so) and check if it need to run something or not.

ps: you could create a /tmp/runwithssh-autoupdate that would scp the file with all ssh commands to execute from the desktop, allowing the laptop to download the new version of the script with new commands in it you had forget to put before you gave the laptop.

this way, laptop is not limited to only use rsync and router is never a problem as it's the laptop that do the connection with his desktop.

----------

## 1clue

Laptops being notoriously off and on all the time, an rsync would make more sense if it were initiated from the laptop anyway.

----------

