summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cloudinit/config/cc_vyos.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/cloudinit/config/cc_vyos.py b/cloudinit/config/cc_vyos.py
index a54c9980..49d8952c 100644
--- a/cloudinit/config/cc_vyos.py
+++ b/cloudinit/config/cc_vyos.py
@@ -84,7 +84,8 @@ def set_ssh_login(config, user, key_string):
logger.error("Key base64 not defined, wrong ssh key format.")
return False
- if not key_parsed.comment:
+ if not key_parsed.comment or not re.fullmatch(r'^[\w]+$', key_parsed.comment, re.ASCII):
+ logger.info("Generating UUID for an SSH key because a comment is empty or unacceptable by CLI")
key_parsed.comment = "cloud-init-{}".format(uuid4())
config.set(['system', 'login', 'user', user, 'authentication', 'public-keys', key_parsed.comment, 'key'], value=key_parsed.base64, replace=True)