mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
backups: Create .ssh folder before creating SSH key
- As a safe guard although it should exist because of a prior verification of SSH key. - Minor refactor to make the method flatter. Tests: - Remove /var/lib/plinth/.ssh and visit add remote repository form. The public key is displayed in the form. The files in /var/lib/plinth/.ssh are created with expected permissions. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
dd0a0f56a6
commit
e21ab91b21
@ -148,15 +148,17 @@ def get_ssh_client_auth_key_paths() -> tuple[Path, Path]:
|
||||
def generate_ssh_client_auth_key():
|
||||
"""Generate SSH client authentication keypair, if needed."""
|
||||
_, key_path = get_ssh_client_auth_key_paths()
|
||||
if not key_path.exists():
|
||||
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)
|
||||
else:
|
||||
key_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
if key_path.exists():
|
||||
logger.info('SSH client key %s for FreedomBox service already exists',
|
||||
key_path)
|
||||
return
|
||||
|
||||
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)
|
||||
|
||||
|
||||
def get_ssh_client_public_key() -> str:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user