File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -604,16 +604,19 @@ def _ReadEntry(self, user_data):
604604 elif not isinstance (ssh_keys , list ):
605605 ssh_keys = []
606606
607- # Create an entry for each SSH key
608- for ssh_key in ssh_keys :
609- if ssh_key and ssh_key .strip ():
610- map_entry = sshkey .SshkeyMapEntry ()
611- map_entry .name = username
612- map_entry .sshkey = ssh_key .strip ()
613- entries .append (map_entry )
614-
615- if ssh_keys :
616- self .log .debug ("Extracted %d SSH keys for user %s" , len (ssh_keys ), username )
607+ # Filter out empty keys and strip whitespace
608+ valid_keys = [key .strip () for key in ssh_keys if key and key .strip ()]
609+
610+ # Create a single entry with all SSH keys as a list
611+ map_entry = sshkey .SshkeyMapEntry ()
612+ map_entry .name = username
613+ if valid_keys :
614+ map_entry .sshkey = valid_keys
615+ else :
616+ # Always create an entry, even if no keys
617+ map_entry .sshkey = ""
618+ self .log .debug ("Extracted %d SSH keys for user %s" , len (valid_keys ), username )
619+ entries .append (map_entry )
617620
618621 return entries
619622
You can’t perform that action at this time.
0 commit comments