jswetzen / docker-rsync-backup

Docker container for remote backup with rsync
GNU General Public License v3.0
8 stars 14 forks source link

Host key verification failed #2

Open DavidMStraub opened 4 years ago

DavidMStraub commented 4 years ago

Hi,

thanks for this useful Dockerfile. Unfortunately I am having some issues. I use the example from the Readme on a Raspberry Pi:

docker run --name rsync-backup \
  --volume <my_named_volume>:/backup \
  --volume /home/pi/.ssh:/ssh-keys \
  --env SSH_IDENTITY_FILE=/ssh-keys/id_rsa \
  --env BACKUPDIR=<my_user>@<my_hostname>:backup \
 jswetzen/rsync-backup:arm32v7

I get:

Host key verification failed.
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: unexplained error (code 255) at io.c(226) [Receiver=3.1.3]

But running directly

rsync --force --ignore-errors --delete --backup \
  -aHAXxv --numeric-ids --progress \
  -e "ssh -Tx -c aes128-gcm@openssh.com -o Compression=no -i /home/pi/.ssh/id_rsa -p22" \
<my_directory> <my_user>@<my_host>:backup

does work (this is rsync 3.1.3 on Raspbian Buster).

Do you have an idea what could be going wrong? Thanks!

jswetzen commented 4 years ago

Almost there! You need to ssh from the root account as well, since Docker is run from root and not your user. Then you’ll be able to type yes to allow the remote key and the backup script will work. Let me know if it doesn’t help.

DavidMStraub commented 4 years ago

Thanks! Unfortunately that didn't do the trick. I did have to type yes when rsyncing from the root account, but it didn't change the error ...

jswetzen commented 4 years ago

Ah, of course it’s the container that hasn’t accepted the host. You could docker exec into the container and ssh from there, but I’m trying to figure out how I got this to work personally... If I look at /root/.ssh/authorized_keys in my container I see the host there, but you will not find your backup host there.

jswetzen commented 4 years ago

I found it now, you need to set the REMOTE_HOSTNAME environmental variable and then the host will be added on the first run of the container.