Common Problems

Permission denied (publickey)

If you want to connect to a repository and get the following (or similar) message:

$ borg init -v --encryption=repokey ssh://borg@makebackups.swagspace.org/./6/101
Remote: borg@makebackups.swagspace.org: Permission denied (publickey).
Connection closed by remote host. Is borg working on the server?

This usually means that the SSH Key that borg presents to the server does not match the key configured.

To verify this connect to the borg repo via SSH and enable debug logging with -v:

$ ssh -v borg@makebackups.swagspace.org
debug1: OpenSSH_10.6p1, OpenSSL 3.6.5 29 Sep 2026
... (lines removed for brevity)
debug1: Will attempt key: /home/jo/.ssh/johannes-thinkpad RSA SHA256:C4SfZAMkcxNUQtNqrrjzbvQw1m1d/61HtjoqFhYiBJA explicit
debug1: Offering public key: /home/jo/.ssh/johannes-thinkpad RSA SHA256:C4SfZAMkcxNUQtNqrrjzbvQw1m1d/61HtjoqFhYiBJA explicit
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
borg@makebackups.swagspace.org: Permission denied (publickey).

Here we can see that SSH offers the key /home/jo/.ssh/johannes-thinkpad. In this case the offered private key does not correspond to the configured public key.

To explicitly specify the key you can use the -i option for ssh:

$ ssh -v -i .ssh/makebackups-repo-test borg@makebackups.swagspace.org 
debug1: OpenSSH_10.6p1, OpenSSL 3.6.5 29 Sep 2026
... (lines removed for brevity)
debug1: Will attempt key: .ssh/makebackups-repo-test ED25519 SHA256:Sdnjn+xLQdx7KtvxtoWkA6043RzAZiC63h3K+eLgCwk explicit
debug1: Will attempt key: /home/jo/.ssh/johannes-thinkpad RSA SHA256:C4SfZAMkcxNUQtNqrrjzbvQw1m1d/61HtjoqFhYiBJA explicit
debug1: Offering public key: .ssh/makebackups-repo-test ED25519 SHA256:Sdnjn+xLQdx7KtvxtoWkA6043RzAZiC63h3K+eLgCwk explicit
debug1: Server accepts key: .ssh/makebackups-repo-test ED25519 SHA256:Sdnjn+xLQdx7KtvxtoWkA6043RzAZiC63h3K+eLgCwk explicit
debug1: identity added to agent: .ssh/makebackups-repo-test
Authenticated to makebackups.swagspace.org ([2003:e7:ef00:dd00:9af2:b3ff:fee6:ac70]:22) using "publickey".
... (lines removed for brevity)

As we can see now the correct key is used

debug1: Offering public key: .ssh/makebackups-repo-test ED25519 SHA256:Sdnjn+xLQdx7KtvxtoWkA6043RzAZiC63h3K+eLgCwk explicit

and accepted by the server

debug1: Server accepts key: .ssh/makebackups-repo-test ED25519 SHA256:Sdnjn+xLQdx7KtvxtoWkA6043RzAZiC63h3K+eLgCwk explicit

So the issue was that ssh presents the wrong key.

To force borg to use this key we can specify the ssh command to use with the --rsh option:

$ borg init --rsh='ssh -i .ssh/makebackups-repo-test' --encryption=repokey ssh://borg@makebackups.swagspace.org/./6/101
Enter new passphrase: 

Now borg asks for the repo passphrase, so authentication worked.