Thumbnail image

Fixing Vorta (Flatpak) Backups Failing on Boot: Pin SSH_AUTH_SOCK for the Sandbox

I use BorgBackup pretty much everywhere - workstations and servers alike. It’s the backup tool I trust most: deduplicating, compressed, encrypted, with append-only repos on my BorgWarehouse server (I’ve written about automating compaction there). On servers I run it headless from systemd timers. On workstations, though, I like a GUI - and for that I use Vorta, a neat desktop app layered on top of Borg, installed as a Flatpak.

For a few weeks now, I had a annoying routine: every time I booted my laptop, the scheduled backups would fail. Vorta is set to autostart, but in practice I had to quit it from the tray and relaunch it by hand before anything worked again. Sometimes the same thing happened after a network change, which was extra confusing - the network was fine, the server was fine, and yet every backup run errored out.

The Symptom

The error in Vorta’s UI was maddeningly generic:

[homedir_daily] ERROR: Connection closed by remote host. Is borg working on the server?

Vorta showing the generic “Connection closed by remote host” error after a failed backup - server and key details masked

“Is borg working on the server?” It was. I could SSH to the repo by hand from a terminal and run borg list without any issue, at the exact same moment the scheduled run was failing. It wasn’t even limited to boot: a daily run in the middle of the day failed the same way.

The Diagnosis

The smoking gun wasn’t in Vorta’s window, it was in the logs. Every failing run logged:

ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory
...
Permission denied (publickey).
...
Connection closed by remote host

Read that chain backwards and the real story appears. Flatpak’s ssh-auth socket forwarding only passes your SSH agent into the sandbox if SSH_AUTH_SOCK is set in the environment of the flatpak run that launches the app. Vorta autostarts at login, and it lost the race: my gcr-ssh-agent socket unit only exports SSH_AUTH_SOCK once it starts, and Vorta came up a second earlier, without the variable. You can confirm it on the running daemon:

$ tr '\0' '\n' < /proc/$(pgrep -f vorta)/environ | grep SSH_AUTH_SOCK
(no output)

Once the process starts without the variable, every backup in it fails the same way: ssh can’t get a signature from the agent, falls back to the identity file, the key is passphrase-protected, ssh tries to prompt through an askpass helper that doesn’t exist inside the Flatpak, authentication fails - and Borg surfaces only the generic “Connection closed by remote host”. I reproduced it by launching the sandbox with SSH_AUTH_SOCK unset: same Permission denied (publickey).

So not a network problem, not a server problem. The network-change failures were just Vorta’s catch-up backup (fired on network-up) being the first thing to hit the already-broken daemon.

The Fix

Pin the agent socket in a per-user Flatpak override, so the sandbox no longer depends on launch-time environment:

flatpak override --user \
  --env=SSH_AUTH_SOCK=/run/user/1000/gcr/ssh \
  --filesystem=xdg-run/gcr \
  com.borgbase.Vorta

The --filesystem=xdg-run/gcr entry lets the sandbox reach the socket under /run/user/1000. Then quit Vorta completely (tray icon β†’ Quit) and relaunch it - a running instance keeps its old environment, so this step matters.

Verify the override landed:

$ flatpak override --user --show com.borgbase.Vorta

[Environment]
SSH_AUTH_SOCK=/run/user/1000/gcr/ssh

[Context]
filesystems=xdg-run/gcr;host;...

To undo it later: flatpak override --user --reset com.borgbase.Vorta - note that this resets all overrides for the app, so check --show first if you have others.

The Flatseal way

If you prefer a GUI, Flatseal edits these exact same per-user overrides - it’s the tool I usually reach for to inspect and fine-tune Flatpak permissions. Two entries for Vorta:

  1. Scroll to Environment β†’ Variables β†’ + and add: SSH_AUTH_SOCK=/run/user/1000/gcr/ssh
  2. In the Filesystem section (above Environment) β†’ Other files β†’ +, add: xdg-run/gcr

Flatseal showing the two overrides for com.borgbase.Vorta: the SSH_AUTH_SOCK environment variable and the xdg-run/gcr filesystem entry

Don’t tick “Filesystem: All system files” or touch the other entries. Then quit and relaunch Vorta, same as above.

Caveats Worth Knowing

  • The 1000 in the path is my user ID. Find your own agent socket with echo $SSH_AUTH_SOCK in a regular shell - with GNOME Keyring it’s usually /run/user/$UID/keyring/ssh, with gcr-ssh-agent it’s /run/user/$UID/gcr/ssh. The --filesystem=xdg-run/<name> entry must match the socket’s directory.
  • The override assumes the agent socket already exists when Vorta launches. At my last login the agent came up about a second before Vorta, so the margin is thin. If failures ever come back after a reboot, the next step is delaying the autostart or making the agent socket unit start earlier.
  • Optional hardening: adding -o BatchMode=yes to BORG_RSH makes ssh fail immediately instead of waiting on a passphrase prompt that can never be answered inside the sandbox - turning this class of failure into a clean, fast error.

Closing Thoughts

What I like about this one is how misleading the UI error was: “Is borg working on the server?” sent me toward the network and the server, while the real error sat two lines up in the log, and the root cause was a one-second race at login. Once the daemon runs without SSH_AUTH_SOCK, nothing in that process can ever authenticate again - which is why quitting and relaunching Vorta by hand always “fixed” it for the rest of the session.

Pinning the socket in the override removes the race entirely. Backups have been green since, on boot and on network changes alike.

Hope this helps!