0

Although the Rsync is available for Windows, there are some problems with SSH. Here is the first one: the files are simply could not be submitted because of unclear error "error in rsync protocol data stream (code 12)". If to specify -e /bin/ssh option, the files could be submitted, but only if remote (e. g. VPS) has the password authentication. However, in real VPS the usage of SSH keys and disabling the authentication by password are basic security requirements. So, the next problem is how to submit the files by Rsync without explicitly specifying of paths to SSH keys (it is important for the automation).

Preparations

I have added the generated keys data to /.ssh/config:

Host 160.XXX.XXX.97(deployer)
  HostName 160.XXX.XXX.97
  User deployer
  IdentityFile ~/.ssh/JXXXXXX-HomePage

To avoid the inputting of passphrase each time, it will required to launch the ssh-agent:

sss config ssh-agent start=auto

Experiment flow

Step 1. Check the normal SSH authentication from PowerShell

Thanks to ssh-agent, the bother is minimal:

ssh [email protected]

enter image description here

Works fine.

Step 2. Check the normal SSH authentication from WSL

Same command:

enter image description here

Works fine.

Step 3. Check the submitting of the files by Rsync + WSL

rsync -azve ssh 04-ProductionBuild [email protected]:/var/www/example.jp

enter image description here

Works fine. Now I have proved that the problem is not on the VPS side.

Step 4. Submitting of the files by Rsync from Windows

rsync -azvr -e /bin/ssh --progress ./04-ProductionBuild/ [email protected]:/var/www/example.jp

enter image description here

The authenticity of host '160.XXX.XX.97 (160.XXX.XX.97)' can't be established. ED25519 key fingerprint is SHA256:NFthXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXTG/Y. This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

Before start experiment, the VPS has been added to the list of known host. Also, the normal SSH authentication works. If to input yes, it will be the error:

Failed to add the host to the list of known hosts (/known_hosts). Connection closed by 160.XXX.XX.97 port 22
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(231) [sender=3.2.7]

1 Answer 1

1
  1. Make sure that your rsync and the (working) ssh are from the same source. Or at least that they are compatible. They have to work together. If your rsync is from WSL then ensure you've installed the ssh client for WSL too, and that your $PATH specifies WSL directories before Windows directories.

  2. It looks like your ssh can't look up your home directory - see the error message Failed to add the host to the list of known hosts (/known_hosts), which has a bad path to the ~/.ssh/known_hosts file.

    Try fixing it with ssh -o 'UserKnownHostsFile=${HOME}/.ssh/known_hosts' remoteHost… or maybe even using an explicit absolute path to the known_hosts file. (NB. Here single quotes are correct, as is the requirement to write the environment variable with curly brackets, ${HOME}.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .