pschiffe / docker-borg

Docker image with BorgBackup client utility and sshfs support
https://hub.docker.com/r/pschiffe/borg/
MIT License
51 stars 18 forks source link

Key authentication not working when Borg/SSH is on another port #22

Closed r-vd-woude closed 3 months ago

r-vd-woude commented 4 months ago

Hello, thanks for the awesome container!

When connecting to my remote repo with the container, I keep getting the following errors:

Connection closed by remote host. Is borg working on the server?
terminating with error status, rc 2

I'm using keys for authentication and have the keys (both id_rsa and id_rsa.pub) mounted under root/.ssh.

My remote repo is not on port 22, but 23. So, for the REPO I have added the following: BORG_REPO='user@remote.repo.net:23/./backups/server'

I don't know how to fix this. Thanks again!

EDIT: borg is on the server, because I can make backups to it with the local install of Borg.

EDIT2: When using a port different than 22, you need to specify ssh://user@.....etc". Withouth the ssh:// part the port gets ignored. I'm just unsure how this container parses that environment variable. Because if I add ssh:// in front of it (ssh://user@remote.repo.net:23/./backups/server) I get the following:

Repository /'ssh:/user@remote.repo.net:23/./backups/server does not exist. terminating with error status, rc 2

pschiffe commented 4 months ago

Hi @r-vd-woude,

I quickly glanced over the script, but I don't think that the BORG_REPO env var is modified by the script. Could you show me exactly how are you creating the container and a complete log from it?

AFAIK this config should work: BORG_REPO='ssh://user@remote.repo.net:23/./backups/server'

Please note, that this syntax, ssh://user@remote.repo.net:23/./backups/server is using path relative to current directory after the SSH connection is established. More info.

r-vd-woude commented 4 months ago

Hi!

Thanks for the shift reply!

I use to following command to run the container: (I normally run it using a compose file, but result is the same)

sudo docker run \

    --name borgbackup \

    -h borgbackup \

    -e BORG_REPO='ssh://user@remote.repo.net:23/./backups/server' \

    -e BORG_PASSPHRASE='verylongandcomplicatedpassword' \

    -e BACKUP_DIRS=/borg/data \

    -e COMPRESSION=zstd \

    -e PRUNE=1 \

    -e KEEP_DAILY=7 \

    -e KEEP_WEEKLY=4 \

    -e KEEP_MONTHLY=6 \

    -v compose_borg_config:/root \

    -v compose_borg_repo:/borg/repo \

    -v compose_borg_ssh:/root/.ssh \

    -v compose_cont_name_data:/borg/data/cont_name:ro \
pschiffe/borg

In the container logs I can only find the following:

Connection closed by remote host. Is borg working on the server? terminating with error status, rc 2

I don't know what is going on really.

pschiffe commented 4 months ago

I've updated the image with debug option. Could you download the latest version from Docker Hub and try again with option -e DEBUG=1? And post the logs.