Rsync: connection unexpectedly closed
tubia opened this issue · comments
Hi,
I am experiencing an issue similar to #18 .
This is my .drone.yml
file:
kind: pipeline
type: docker
name: default
steps:
- name: deploy
image: drillster/drone-rsync
environment:
RSYNC_KEY:
from_secret: ssh_key
RSYNC_USER:
from_secret: user
settings:
hosts:
- test.example.com
source: ./
target: ~/myfolder
script:
- touch test
This is the log of the build
job:
latest: Pulling from drillster/drone-rsync
Digest: sha256:<hash>
Status: Image is up to date for drillster/drone-rsync:latest
Port not specified, using default port 22!
$ rsync -az -e 'ssh -p 22 -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o StrictHostKeyChecking=no' ./ ******@test.example.com:~/myfolder ...
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.3]
Any idea on how to debug this?
That's a very generic error from rsync, no real way of telling what's wrong.
You can run it locally outside of Drone as explained here: https://github.com/Drillster/drone-rsync#usage. Play around with the various options and settings to see if you can get it to work, then copy what you have to your Drone configuration.
Hi @mjwwit thanks for your reply.
I followed what you suggested and, passing to PLUGIN_KEY
the output of cat id_rsa | tr -d '\n'
I got this error when running the docker image as suggested:
Load key "/root/.ssh/id_rsa": invalid format
This is the command I use:
docker run --rm -e PLUGIN_KEY="-----BEGIN RSA PRIVATE KEY-----things-----END RSA PRIVATE KEY-----" -e PLUGIN_HOSTS="mysubdomain.example.com" -e PLUGIN_PORTS="22" -e PLUGIN_TARGET="~/" -e PLUGIN_USER="myuser" -e PLUGIN_PRESCRIPT="echo \"Prescript Done\"" -e PLUGIN_SCRIPT="echo \"Postscript Done\"" drillster/drone-rsync
I think the newlines may be required in the private key file. If you're using a secret to store the private key you should look at the Drone documentation, as it explains how to add the contents of a file (including newlines) to a secret.
@tubia
I had a similar problem. I found out that after I copied the private key from my terminal screen some whitespaces were added. Copy it into a text editor first to see if you don't have any extra whitespaces before each newline, and then copy it into your drone repository settings page after you've removed the whitespaces.
I'm closing this now. Anyone experiencing this should check the format of their private key.
you kan try adding the local pubilc key file to the authorized_keys file