backups: Create a better comment in the generated SSH key file

Tests:

- When /var/lib/plinth/.ssh is deleted and add remote repository form is
visited, the directory along with SSH key files are created. The .pub file has
the expected comment freedombox@configured_domain.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Sunil Mohan Adapa 2026-02-05 22:24:16 -08:00
parent 4ae66c034c
commit 5da5ef5f96
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -15,6 +15,7 @@ from django.utils.translation import gettext_noop
from plinth import app as app_module
from plinth import cfg, glib, menu
from plinth.modules.names.components import DomainName
from plinth.package import Packages
from . import api, errors, manifest, privileged
@ -154,11 +155,14 @@ def generate_ssh_client_auth_key():
key_path)
return
domain_name = DomainName.list_names()[0]
logger.info('Generating SSH client key %s for FreedomBox service',
key_path)
subprocess.run(
['ssh-keygen', '-t', 'ed25519', '-N', '', '-f',
str(key_path)], stdout=subprocess.DEVNULL, check=True)
subprocess.run([
'ssh-keygen', '-t', 'ed25519', '-N', '', '-C',
f'freedombox@{domain_name}', '-f',
str(key_path)
], stdout=subprocess.DEVNULL, check=True)
def get_ssh_client_public_key() -> str: