From 4847c4ac64982bbf4fd88419f571311596fa4274 Mon Sep 17 00:00:00 2001 From: vegano1 Date: Mon, 11 Sep 2023 11:35:26 -0400 Subject: [PATCH] create .ssh dir if it does not exist --- server-utils/server_utils/ssh_keys.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server-utils/server_utils/ssh_keys.py b/server-utils/server_utils/ssh_keys.py index 504ee7469eb..81e95cd3a7a 100644 --- a/server-utils/server_utils/ssh_keys.py +++ b/server-utils/server_utils/ssh_keys.py @@ -6,7 +6,8 @@ from typing import Dict, Optional -AUTHORIZED_KEYS = os.path.expanduser("~/.ssh/authorized_keys") +SSH_DIR = Path(os.path.expanduser("~/.ssh")) +AUTHORIZED_KEYS = SSH_DIR / "authorized_keys" def add_ssh_keys_from_usb(path: Optional[Path] = None) -> None: @@ -24,6 +25,8 @@ def add_ssh_keys_from_usb(path: Optional[Path] = None) -> None: # Load the current keys and hash them if we have any current_keys = dict() + if not os.path.exists(SSH_DIR): + os.mkdir(SSH_DIR, mode=0o700) if os.path.exists(AUTHORIZED_KEYS): with open(AUTHORIZED_KEYS, "r") as fh: current_keys = {