ssh: don't fail if a possible key's pubkey file doesn't exist

This commit is contained in:
InsanePrawn 2021-10-25 20:47:17 +02:00
parent 525c012d9c
commit 2209447af0

6
ssh.py
View file

@ -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())