SSH Keys for BorgBase
Introduction
Section titled “Introduction”SSH (or Secure Shell) was invented as a more secure replacement for telnet. It is used to connect to a remote server and run commands, transfer files, or forward traffic. If you do anything remotely related to servers or websites, you have probably heard about it.
BorgBackup also uses SSH to securely connect to a backup server and transfer files. It does this by starting another server on the remote end, which makes it quicker than using SFTP (a subset of SSH to transfer files) directly.
To use SSH, you need a keypair, which consists of a public and a private key. The private key should always stay on your local machine. The public key can be added to remote services (like BorgBase), so you can authenticate yourself to the remote service. This is more convenient and secure than using a password because a key is much longer than a typical password.
Supported SSH Key Types
Section titled “Supported SSH Key Types”BorgBase supports the following SSH key types for secure authentication:
| Key Type | Identifier | Notes |
|---|---|---|
| ECDSA P-384 | ecdsa-sha2-nistp384 |
Recommended |
| ECDSA P-521 | ecdsa-sha2-nistp521 |
Supported |
| RSA | ssh-rsa |
At least 2048 bit, 3072 bit or more for new keys |
| Ed25519 | ssh-ed25519 |
Supported, not recommended for new keys |
| ECDSA P-256 | ecdsa-sha2-nistp256 |
Supported, not recommended for new keys |
We recommend ECDSA P-384 keys for new setups. In December 2026, the NSA advised moving away from elliptic curves other than P-384 and P-521, which includes Ed25519 and P-256.1 No practical attack has been published, but upstream OpenSSH switched its default key type to P-384 in response.2
Post-quantum SSH keys (ssh-mldsa44-ed25519, available in OpenSSH 10.6 and newer) are not supported yet.
How to Create SSH Keys
Section titled “How to Create SSH Keys”Step 1 – Ensure OpenSSH Is Available
Section titled “Step 1 – Ensure OpenSSH Is Available”OpenSSH is the default SSH server and client used on most Linux distributions and on macOS. It comes with utilities to generate keys. It’s already pre-installed on macOS, and on Ubuntu or Debian it is installed most of the time. Run the following command to make sure it works:
ssh -VIf OpenSSH is already installed, it prints its version, for example:
OpenSSH_9.9p1, OpenSSL 3.5.1 1 Jul 2025If the above command gives an error, you can install OpenSSH using this command on Ubuntu or Debian (on other distributions this may differ):
sudo apt-get install openssh-clientStep 2 – Create Keypair
Section titled “Step 2 – Create Keypair”As computers get faster and cryptanalysis improves, encryption needs to adjust. That’s why the recommended key algorithm and key length have changed over the years. The recommended key generation setting is:
ssh-keygen -t ecdsa -b 384This generates an ECDSA key on the NIST P-384 curve. Be sure to include -b 384: without it, most OpenSSH versions create a P-256 key. If you prefer to use RSA, you can also use:
ssh-keygen -t rsa -b 4096After choosing an appropriate key format and length, the command asks where to save the key and whether to set a passphrase. Using the default location in ~/.ssh/id_ecdsa or ~/.ssh/id_rsa is generally OK and OpenSSH will easily find keys later. For automated backups, leave the passphrase empty (see below).
Step 3 – Use the Public Key for Backups
Section titled “Step 3 – Use the Public Key for Backups”When done, you will find your newly generated key in ~/.ssh. To view your public key:
cat ~/.ssh/id_ecdsa.pubOr if you chose an RSA key:
cat ~/.ssh/id_rsa.pubThis prints your public key. (Please don’t upload your private key.)
ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQ...LqRJw+dl/E+2BJ user@serverYou can now copy it to the clipboard and add it in the BorgBase control panel under SSH Keys.
Finally, be sure to also assign the key to a backup repository — otherwise it won’t be used. When adding or editing a backup repository, you can assign any of your SSH keys under the Access tab. It’s good practice to have one keypair per server or machine, so each machine can only access its own backups.
During repository initialization, Borg will use the key without any further settings.
Keys, Passwords and Passphrases
Section titled “Keys, Passwords and Passphrases”BorgBase uses SSH keys for authentication. This means to connect to a backup repository, you upload the public part of an SSH keypair and use the private part to make a connection.
The SSH key and the Borg repository passphrase are completely separate. SSH keys are only used for authentication to log in to the BorgBase repository, and you can easily replace them in the control panel.
It’s possible to create an encrypted SSH key that’s protected with a passphrase. We don’t recommend this for backup purposes, since it doesn’t add much security and can interfere with automation. It’s preferred to generate an SSH key without a passphrase and keep it on that one machine only. If the same Borg repository is used from another machine, generate a new key there.
In addition, SSH also supports login by password. This doesn’t work well with automation and isn’t supported by BorgBase. If you are prompted for an SSH password, there is an issue with your SSH key.
The Borg repository passphrase is used for encryption and is separate from SSH. It encrypts the backup data on your machine, and we can’t help you recover or replace it. You should keep it somewhere safe off the source machine so you always have access to the backup, even if something happens to the source machine.
To summarize the terms again:
- SSH key: The private part of a keypair used to authenticate with an SSH server. Used by BorgBase for authentication when connecting to a Borg repository.
- SSH password: Another way to authenticate with an SSH server. Not used by BorgBase.
- SSH key passphrase: Used to encrypt an SSH key.
- Borg repository passphrase: Used to encrypt the data in a Borg repository.
If connections fail, see Connection and SSH Issues.
Footnotes
Section titled “Footnotes”-
What to Make of the NSA Advisory (Filippo Valsorda, December 2026) ↩
-
OpenSSH: switch default key type generated to ECDSA NISTP384 ↩