From 2209447af058a9a9831ddbdcd8d275ab4e81ed1a Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Mon, 25 Oct 2021 20:47:17 +0200 Subject: [PATCH] ssh: don't fail if a possible key's pubkey file doesn't exist --- ssh.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ssh.py b/ssh.py index ce82020..c854273 100644 --- a/ssh.py +++ b/ssh.py @@ -97,5 +97,9 @@ def copy_ssh_keys(root_dir: str, user: str): with open(authorized_keys_file, 'a') as authorized_keys: for key in keys: - with open(f'{key}.pub', 'r') as file: + pub = f'{key}.pub' + if not os.path.exists('pub'): + logging.debug(f'Skipping key {key}: {pub} not found') + continue + with open(pub, 'r') as file: authorized_keys.write(file.read())