From 9f74617272043685bbf2a3725947c0003e555798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Loipf=C3=BChrer?= <michael.loipfuehrer@stusta.de> Date: Tue, 25 Jun 2019 21:36:11 +0000 Subject: [PATCH] working user management --- lustmolch.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lustmolch.py b/lustmolch.py index f671b10..2f46dad 100755 --- a/lustmolch.py +++ b/lustmolch.py @@ -288,7 +288,7 @@ def add_user(config_file, key_string, name, key): default=DEFAULT_CONF_FILE, help='Container configuration file') @click.argument('name') -def remove_user(config_file, name) +def remove_user(config_file, name): cfg = get_config(config_file) if name in cfg['users']: del cfg['users'][name] @@ -309,9 +309,11 @@ def update_containers(dry_run, config_file): for container in cfg['containers'].values(): ssh_dir = Path('/var/lib/machines', container['name'], 'root/.ssh') authorized_keys = ssh_dir / 'authorized_keys' + + keys = [user['key'] for user in cfg['users'].values() if user['name'] in container['users']] + keys = '\n'.join(keys) - keys = '\n'.join([user['key'] if user['name'] in container['users'] for user in cfg['users']]) - click.echo(f'Writing\n\n{keys}\n to authorized key file {authorized_keys}') + click.echo(f'Writing\n{keys}\n to authorized key file {authorized_keys}') if not dry_run: ssh_dir.mkdir(mode=0o700, parents=True, exist_ok=True) authorized_keys.touch(mode=0o600, exist_ok=True) -- GitLab