Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1250
  • Last Modified:

trouble using rsync wth a different port

I have 2 linux hosts behind a router. The router forwards port 22 to host A's port 22. The router forwards port 20020 to host B's port 22. The router has a public address at myhost.com

This works fine for ssh and scp. I can do 'ssh myhost.com' and log into host A, and I can do 'ssh -p 20020  myhost.com' and log into host B.

However, when I try:

rsync --port=20020 myhost.com:/remotefolder/ /localfolder

it is actually trying to connect to host A, not host B. I can see this in host A's /var/log/messages:

Invalid user joe from 1.2.3.4

No attempted login appears in B's /var/log/messages.

I've also tried:

rsync rsync://myhost.com:20020/remotefolder/ /localfolder

and get the error, "rsync: server sent "SSH-2.0-OpenSSH_5.8" rather than greeting"

So, what am I doing wrong?
0
jmarkfoley
Asked:
jmarkfoley
  • 3
  • 3
  • 3
1 Solution
 
joolsCommented:
Don't you need something like --rsh=ssh I forget the exact syntax but the man page should have it.
0
 
joolsCommented:
Oh, hang on, does user joe exist? You can use userid@myhost.com though
0
 
jmarkfoleyAuthor Commented:
> Don't you need something like --rsh=ssh

I don't know why I would need that, or what I would put if I do. ssh doesn't work normally. Anyway, I don't think I'm getting that far. The --port option seems to be ignored and the rsync request is routing to host A, not host B which is where the target port 20020 is being forwarded in the first place, so I don't even get why the requests is appearing at host A!?
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
joolsCommented:
You would do something like sync -rsh=ssh blah

You would usually get connection info at both ends, also you need to make sure user Joe exists or specify this on the destination host.
0
 
crazedsanityCommented:
If the port on the destination machine is port 22 (forwarded from a different port on the router or not), then SSH is in the mix.  You'll need to pass the options to SSH:
rsync -avz -e "ssh -p 20020" user@remoteip:/path/to/files/ /local/path/

Open in new window

 (found via a google search:  [http://lmgtfy.com/?q=rsync+with+ssh+on+non-standard+port])
0
 
jmarkfoleyAuthor Commented:
By golly that did it! I checked out your link and it really didn't seem like my situation. It seemed to talk about using a different port on the remote machine whereas the port on the remote machine is still 22. But, I thought "what the heck" and tried the -e "ssh -p <port>" syntax without using --port=20020, and it worked! It makes me wonder what the --port option is for, but never mind; that's for another day.
0
 
crazedsanityCommented:
The way you're using rsync basically just tunnels through SSH, so the connection iformation such as port must be passed to the SSH client.  Using the "--port" flag is probably a lot different than what you'd expect, check out the manual page online here: [http://linux.die.net/man/1/rsync].
0
 
jmarkfoleyAuthor Commented:
I've got the same rsync man page. I guess the --port option is for *listening* on an alternate port for daemon use. In browsing through the man page looking at -e examples I didn't see anything as clear/obvious as your example. "rsh" was referenced and I'm using "ssh" (that use of "rsh" didn't strike me as 'generic'). Nor was there a clear example of passing the port within the -e string, ... and numerous other things not entirely clear (to me). Just make sure you hang around EE for a while 'cause you seem pretty knowledgable on this stuff!!

Thanks!
0
 
crazedsanityCommented:
Glad I could help. And thanks for the compliment. :)
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

  • 3
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now