From 2ce857248162957a785af61c135ca8433fdbbcde Mon Sep 17 00:00:00 2001 From: Emanuele Giuseppe Esposito Date: Wed, 8 Sep 2021 02:08:36 +0200 Subject: ssh_utils.py: ignore when sshd_config options are not key/value pairs (#1007) As specified in #LP 1845552, In cloudinit/ssh_util.py, in parse_ssh_config_lines(), we attempt to parse each line of sshd_config. This function expects each line to be one of the following forms: \# comment key value key=value However, options like DenyGroups and DenyUsers are specified to *optionally* accepts values in sshd_config. Cloud-init should comply to this and skip the option if a value is not provided. Signed-off-by: Emanuele Giuseppe Esposito --- cloudinit/ssh_util.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'cloudinit') diff --git a/cloudinit/ssh_util.py b/cloudinit/ssh_util.py index 9ccadf09..33679dcc 100644 --- a/cloudinit/ssh_util.py +++ b/cloudinit/ssh_util.py @@ -484,7 +484,13 @@ def parse_ssh_config_lines(lines): try: key, val = line.split(None, 1) except ValueError: - key, val = line.split('=', 1) + try: + key, val = line.split('=', 1) + except ValueError: + LOG.debug( + "sshd_config: option \"%s\" has no key/value pair," + " skipping it", line) + continue ret.append(SshdConfigLine(line, key, val)) return ret -- cgit v1.2.3