diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-07-05 12:24:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-05 12:24:53 +0200 |
commit | cac6da1e3038cba22735eafd9f8b4ec13359a2d7 (patch) | |
tree | c5280efc973be4fe0b9a77b38069ae4b8d9332c0 /src/op_mode | |
parent | f315714d0c680ad80a79dcdac21576407794dcd1 (diff) | |
parent | 4e6dbe819241dbf343a687bd98ab29749e75813b (diff) | |
download | vyos-1x-cac6da1e3038cba22735eafd9f8b4ec13359a2d7.tar.gz vyos-1x-cac6da1e3038cba22735eafd9f8b4ec13359a2d7.zip |
Merge pull request #1381 from sever-sever/T4313-eq
T4313: handle exceptions in the "generate public-key-command" script
Diffstat (limited to 'src/op_mode')
-rwxr-xr-x | src/op_mode/generate_public_key_command.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/op_mode/generate_public_key_command.py b/src/op_mode/generate_public_key_command.py index 7a7b6c923..f071ae350 100755 --- a/src/op_mode/generate_public_key_command.py +++ b/src/op_mode/generate_public_key_command.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2021 VyOS maintainers and contributors +# Copyright (C) 2022 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as @@ -29,8 +29,12 @@ def get_key(path): key_string = vyos.remote.get_remote_config(path) return key_string.split() -username = sys.argv[1] -algorithm, key, identifier = get_key(sys.argv[2]) +try: + username = sys.argv[1] + algorithm, key, identifier = get_key(sys.argv[2]) +except Exception as e: + print("Failed to retrieve the public key: {}".format(e)) + sys.exit(1) print('# To add this key as an embedded key, run the following commands:') print('configure') @@ -39,3 +43,4 @@ print(f'set system login user {username} authentication public-keys {identifier} print('commit') print('save') print('exit') + |