cwrsync with plink gives "connection unexpectedly closed"

11 posts / 0 new
Last post
itefix
Offline
Last seen: 2 weeks 1 hour ago
Joined: 01.05.2008 - 21:33
cwrsync with plink gives "connection unexpectedly closed"

Hi,
I'm giving up :-] I've been trying to get cwrsync 2.0.4 running with plink for about two hours, but it doesn't work.

First of all, this is what runs without any problems:
- cwrsync with the supplied ssh (requests password, that's what I want to avoid in the first place)
- plink -l user host (of course still requests password)
- plink -i path\to\key -l user host (that's what I want)

From that point of view I'd say everything should be fine and cwrsync + plink should work, too. Doesn't, though.

For the following, the rsync command is always

rsync -aznvvvvv . me@example.com:some/path

If I try to use plink as a 1:1 replacement for ssh, i.e. with password authentication, it doesn't ask for a password and just exists with "Access denied".

set RSYNC_RSH=plink

cmd= machine=example.com user=me path=some/path
cmd=plink -l me example.com rsync --server -vvvvvnlogDtprz . some/path
opening connection using plink -l st bitbrook.de rsync --server -vvvvvnlogDtprz . some/path
Access denied
Access denied
FATAL ERROR: Server sent disconnect message type 2
(SSH_DISCONNECT_PROTOCOL_ERROR): "Too many authentication failures for me"
rsync: connection unexpectedly closed (0 bytes received so far)
_exit_cleanup(code=12, file=io.c, line=434): entered
rsync error: error in rsync protocol data stream (code 12) at io.c(434)
_exit_cleanup(code=12, file=io.c, line=434): about to call exit(12)

Trying to use public key authentication gives me an "unexpectecdly closed" error. Authentication does work, however, as the server's sshd logs a successfull login.

set RSYNC_RSH=plink -i path\to\key

cmd= machine=example.com user=me path=some/path
cmd=plink.exe -i path/to/key -l me example.com rsync --server -vvvvvnlogDtprz .
opening connection using plink.exe -i "path\\to\\key" -l me example.com rsync --server -vvvvvnlogDtprz . some/path
rsync: connection unexpectedly closed (0 bytes read so far)
_exit_cleanup(code=12, file=io.c, line=189): entered
rsync error: error in rsync protocol data stream (code 12) at io.c(189)
_exit_cleanup(code=12, file=io.c, line=189): about to call exit(12)
rsync: connection unexpectedly closed (0 bytes received so far)
_exit_cleanup(code=12, file=io.c, line=434): entered
rsync error: error in rsync protocol data stream (code 12) at io.c(434)
_exit_cleanup(code=12, file=io.c, line=434): about to call exit(12)

Any idea's what's wrong?

Thanks a lot!

itefix
Offline
Last seen: 2 weeks 1 hour ago
Joined: 01.05.2008 - 21:33
Re: cwrsync with plink gives "connection unexpectedly closed"

How did you create your private key for plink ? ssh and plink use different formats.

itefix
Offline
Last seen: 2 weeks 1 hour ago
Joined: 01.05.2008 - 21:33
Re: cwrsync with plink gives "connection unexpectedly closed"

How did you create your private key for plink ? ssh and plink use different formats.

The key authentication with plink works fine. As I wrote, I can log in using

plink -i path\to\key -l user host

so plink itself works, the key is fine and the command line, too.

Second, if I use cwrsync with plink and key authentication, the ssh server logs a successfull login, so plink must have established a connection for rsync to use. The problem must be in the communication rsync tries to establish with the remote rsync.

I've added -v to plink's command line, gives me this additional output:

We claim version: SSH-2.0-PuTTY-Release-0.57
Using SSH protocol version 2
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange
Host key fingerprint is:
ssh-rsa 1024 42:and:so:on
Initialised AES-256 client->server encryption
Initialised AES-256 server->client encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised HMAC-SHA1 server->client MAC algorithm
Using username "me".
Reading private key file "path\to\key"
Offered public key
Offer of public key accepted
Authenticating with public key "me@example"
Access granted
Opened channel for session
Started a shell/command
Sent EOF message
Server sent command exit status 12
rsync: connection unexpectedly closed (0 bytes read so far)

itefix
Offline
Last seen: 2 weeks 1 hour ago
Joined: 01.05.2008 - 21:33
Re: cwrsync with plink gives "connection unexpectedly closed"

What kind of rsync daemon do you try to connect to ? Is it cwRsync Server or linux/unix ?

itefix
Offline
Last seen: 2 weeks 1 hour ago
Joined: 01.05.2008 - 21:33
Re: cwrsync with plink gives "connection unexpectedly closed"

Genuine rsync 2.6.0 on a Linux box.
I've by now tried the following:

cwrsync + ssh: Works both with password and key authentication
plink (alone): Works both with password and key authentication
cwrsync + plink: Doesn't work, neither with password nor key authentication

Since the server's rsync exits with code 12 (error in rsync protocol data stream) I tried the clean-connection-test (plink -i path\to\key -l me example.com /bin/true > out.txt) suggested in rsync's manual: out.txt is 0 bytes as it should, so there's no shell garbage disturbing rsync.

Finally, I've run only the remote rsync using

plink.exe -v -i path\to\key -l me example.com rsync --server -vvvvvnlogDtprz . some/path

This works as far as the connection stays up and rsync is running on the server. After pressing some key it returns (of course) a protocol error:

← (Server) Protocol versions: remote=858927408, negotiated=27
protocol version mismatch - is your shell clean?
(see the rsync man page for an explanation)
_exit_cleanup(code=2, file=compat.c, line=70): entered
rsync error: protocol incompatibility (code 2) at compat.c(70)
_exit_cleanup(code=2, file=compat.c, line=70): about to call exit(2)

So, data can be exchanged and I somehow suspect the problem in the local rsync being unable to read from plink.

itefix
Offline
Last seen: 2 weeks 1 hour ago
Joined: 01.05.2008 - 21:33
Re: cwrsync with plink gives "connection unexpectedly closed"

Genuine rsync 2.6.0 on a Linux box.
cwrsync + plink: Doesn't work, neither with password nor key authentication

I should add they have different error codes, though. Password doesn't work because plink does not request a password at all, thus of course making the server return an "Access denied". Key doesn't work because the connection goes away _after_ authentication.

itefix
Offline
Last seen: 2 weeks 1 hour ago
Joined: 01.05.2008 - 21:33
Re: cwrsync with plink gives "connection unexpectedly closed"

I've run into exactly the same issue, and I would guess it's a text mode/binary mode incompatibility. Try this simple test in the standard Windows cmd-shell, first:
ssh user@somehost.com ls -lR > dump-ssh.dat

and then:

plink user@somehost.com ls -lR > dump-plink.dat

and the results is as follows: dump-ssh.dat has CR/LF line endings while dump-plink.dat has LF line endings. So somehow the rsync communication with the ssh-channel on the client side expects CR/LF line endings for at least part of the conversation. It wouldn't be that difficult to modify the plink source to optionally operate in text mode, and then try it out.

itefix
Offline
Last seen: 2 weeks 1 hour ago
Joined: 01.05.2008 - 21:33
Re: cwrsync with plink gives "connection unexpectedly closed"

Genuine rsync 2.6.0 on a Linux box.

Since the problem seems to be related to rsync, upgrading linux side to version 2.6.6 might be worth trying.

itefix
Offline
Last seen: 2 weeks 1 hour ago
Joined: 01.05.2008 - 21:33
Re: cwrsync with plink gives "connection unexpectedly closed"

Genuine rsync 2.6.0 on a Linux box.

Since the problem seems to be related to rsync, upgrading linux side to version 2.6.6 might be worth trying.

I'd do that as soon as possible if could :]

But the cr/lf-issue seems to be a pretty good guess. I can confirm that the output differs between ssh and plink, and unexpected (or missing) bytes fits in the protocol violation reports by rsync. Makes sense to me.

Would be interesting to hear from someone who has no problems in using rsync with plink. tev, if a successfull plink user comes around maybe you could ask him which line endings his plink produces? If it's cr/lf the case would be clear.

Thanks everybody (and thanks for cwrsync itself, of course)!

itefix
Offline
Last seen: 2 weeks 1 hour ago
Joined: 01.05.2008 - 21:33
Re: cwrsync with plink gives "connection unexpectedly closed"

I read this article: http://www.linuxquestions.org/questions/showthread.php?threadid=349608
It got me wondering if the welcome message output by my remote linux server was causing plink/rsync to have an unexpected error. I have a Dreamhost account, and at login I get a standard message:

Any malicious and/or unauthorized activity is strictly forbidden.
All activity may be logged by DreamHost Web Hosting.

So, is the fact that the server is spewing text to plink causing the problem? Can anyone test this out on a server where they can turn the welcome message on and off?

itefix
Offline
Last seen: 2 weeks 1 hour ago
Joined: 01.05.2008 - 21:33
Re: cwrsync with plink gives "connection unexpectedly closed"

Hello
What an old thread without a solution.

I'm missing the Option >>--rsync-path="/path/to/rsync/binary/rsync">rsync ...

Topic locked

Release announcements