diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-06-18 23:04:46 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-06-18 23:04:48 +0200 |
commit | e59da2923cbbb21258cc9769b6a152d6af78abe6 (patch) | |
tree | 3a54084962628c6faf15299daab3067586453625 /src/conf_mode | |
parent | 067ddcf27ac1fbc33cee710ae66a85b0368a26d9 (diff) | |
download | vyos-1x-e59da2923cbbb21258cc9769b6a152d6af78abe6.tar.gz vyos-1x-e59da2923cbbb21258cc9769b6a152d6af78abe6.zip |
console-server: T2490: add SSH support
A user can define a port under the SSH node per device. WHen connecting to that
port and authenticating using regular credentials we will immediately drop to
the serial console. This is the same as executing "connect serial-proxy <name>".
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-x | src/conf_mode/service_serial-proxy.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/conf_mode/service_serial-proxy.py b/src/conf_mode/service_serial-proxy.py index 0dd1cfc6d..5f510d311 100755 --- a/src/conf_mode/service_serial-proxy.py +++ b/src/conf_mode/service_serial-proxy.py @@ -65,11 +65,11 @@ def verify(proxy): for tmp in proxy['device']: device = proxy['device'][tmp] if not device['speed']: - raise ConfigError(f'Speed must be defined!') + raise ConfigError(f'Serial port speed must be defined for "{tmp}"!') - if device['ssh']: - if not device['ssh']['port']: - raise ConfigError(f'SSH port must be defined!') + if 'ssh' in device.keys(): + if 'port' not in device['ssh'].keys(): + raise ConfigError(f'SSH port must be defined for "{tmp}"!') return None @@ -81,13 +81,20 @@ def generate(proxy): return None def apply(proxy): + call('systemctl stop conserver-server.service') + call('systemctl stop dropbear@*.service') + if not proxy: - call('systemctl stop conserver-server.service') if os.path.isfile(config_file): os.unlink(config_file) return None call('systemctl restart conserver-server.service') + + for device in proxy['device']: + if 'ssh' in proxy['device'][device].keys(): + call('systemctl restart dropbear@{device}.service') + return None if __name__ == '__main__': |