diff options
author | khramshinr <khramshinr@gmail.com> | 2024-12-11 11:51:10 +0800 |
---|---|---|
committer | khramshinr <khramshinr@gmail.com> | 2024-12-16 15:16:34 +0800 |
commit | 73b9eba81999744ba0adf4c252ccdb2bd0bd2a19 (patch) | |
tree | 4179cedb7da1fb9610aafb88baa366d75dc3aef7 /src/op_mode/generate_psk.py | |
parent | 221b384ff0096f07b96f13d1a5433e0b49c15846 (diff) | |
download | vyos-1x-73b9eba81999744ba0adf4c252ccdb2bd0bd2a19.tar.gz vyos-1x-73b9eba81999744ba0adf4c252ccdb2bd0bd2a19.zip |
T6934: Add preshared key for zabbix-agent monitoring service
- Allow configure preshared key for zabbix-agent
- Added op mode command for generatre random psk secret
- Removed duplicate xml definition for psk settings
Configure authentication mode:
```
# set service monitoring zabbix-agent authentication mode
Possible completions:
pre-shared-secret Use a pre-shared secret key
```
Configure PSK Settings:
```
# set service monitoring zabbix-agent authentication psk
Possible completions:
id ID for authentication
secret pre-shared secret key
```
Generate Random PSK:
```
$ generate psk random
Possible completions:
<Enter> Execute the current command
size Key size in bytes
```
Diffstat (limited to 'src/op_mode/generate_psk.py')
-rw-r--r-- | src/op_mode/generate_psk.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/op_mode/generate_psk.py b/src/op_mode/generate_psk.py new file mode 100644 index 000000000..d51293712 --- /dev/null +++ b/src/op_mode/generate_psk.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2024 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 +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +import argparse + +from vyos.utils.process import cmd + + +def validate_hex_size(value): + """Validate that the hex_size is between 32 and 512.""" + try: + value = int(value) + except ValueError: + raise argparse.ArgumentTypeError("hex_size must be integer.") + + if value < 32 or value > 512: + raise argparse.ArgumentTypeError("hex_size must be between 32 and 512.") + return value + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument( + "--hex_size", + type=validate_hex_size, + help='PKS value size in hex format. Default is 32 bytes.', + default=32, + + required=False, + ) + args = parser.parse_args() + + print(cmd(f'openssl rand -hex {args.hex_size}'))
\ No newline at end of file |