Skip to content

Commit

Permalink
create .ssh dir if it does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
vegano1 committed Sep 11, 2023
1 parent abbcd8b commit 4847c4a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server-utils/server_utils/ssh_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 = {
Expand Down

0 comments on commit 4847c4a

Please sign in to comment.