Skip to content

Instantly share code, notes, and snippets.

@Tao-Automata
Created August 30, 2025 02:35
Show Gist options
  • Select an option

  • Save Tao-Automata/bdba5cc1b33c9784098922eef1bb71cf to your computer and use it in GitHub Desktop.

Select an option

Save Tao-Automata/bdba5cc1b33c9784098922eef1bb71cf to your computer and use it in GitHub Desktop.
Remotely upgrade Tailscale via Tailscale SSH (Resolve `E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.` issue)

If you have a Tailscale server running remotely and wanna upgrade the tailscale via apt update && apt upgrade, you are likely to have an issue that the SSH connection dropped when dpkg is configuring the tailscale daemon.

And you will get stuck there with an error

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

But you cannot run and finish it before the connection dropped.

AI agent or someone suggests to use tmux, nohup or screen, but from my experience, neither of them will work.

My solution is to add a service in systemd by the following steps:

  1. Create a new service file

You'll create a new service file in the /etc/systemd/system/ directory. The standard convention is to name it something descriptive, ending with .service.

sudo vim /etc/systemd/system/fix-tailscale.service

with the following content:

[Unit]
Description=Fix dpkg script
After=network.target

[Service]
Type=simple
ExecStart=/bin/bash -c 'dpkg --configure -a'
User=root

[Install]
WantedBy=multi-user.target
  1. Reload the service config
sudo systemctl daemon-reload
  1. Enable and run the service
sudo systemctl enable fix-tailscale.service
sudo systemctl start fix-tailscale.service

Now, your SSH connection will drop one-more time, but it will fix the issue and complete the upgrade this time. Cheers :)

@Ilan-Sperber
Copy link

Thank you 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment