2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-02-28 08:11:45 +00:00

Rework ssh key init to reset key and use context management

This commit is contained in:
Jarrod Johnson 2024-08-14 16:08:02 -04:00
parent 83a4df49c7
commit 82e0d9c434

View File

@ -215,12 +215,13 @@ def initialize_root_key(generate, automation=False):
suffix = 'rootpubkey'
keyname = '/var/lib/confluent/public/site/ssh/{0}.{1}'.format(
myname, suffix)
if authorized:
with open(keyname, 'w'):
pass
for auth in authorized:
local_key = open(auth, 'r')
dest = open(keyname, 'a')
dest.write(local_key.read())
local_key.close()
dest.close()
with open(auth, 'r') as local_key:
with open(keyname, 'a') as dest:
dest.write(local_key.read())
if os.path.exists(keyname):
os.chmod(keyname, 0o644)
os.chown(keyname, neededuid, -1)