From 2691e9d47d45be9a72798bd84166d09b5c3c8d82 Mon Sep 17 00:00:00 2001 From: Sergio Durigan Junior Date: Jun 07 2020 21:16:15 +0000 Subject: Make sure authorized_keys file has mode 600. Only the pagure user needs to be able to read and write the file. --- diff --git a/pagure/lib/tasks.py b/pagure/lib/tasks.py index eaef5cd..73323ef 100644 --- a/pagure/lib/tasks.py +++ b/pagure/lib/tasks.py @@ -1270,6 +1270,7 @@ def add_key_to_authorized_keys(self, session, ssh_folder, username, sshkey): sshkey.strip(), ) ) + os.chmod(fullpath, 0o600) @conn.task(queue=pagure_config.get("AUTHORIZED_KEYS_QUEUE", None), bind=True) @@ -1294,3 +1295,4 @@ def remove_key_from_authorized_keys(self, session, ssh_folder, sshkey): with open(fullpath, "w") as stream: stream.write("\n".join(output)) + os.chmod(fullpath, 0o600)