Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14164 +/- ##
============================================
- Coverage 19.89% 19.89% -0.01%
- Complexity 20144 20149 +5
============================================
Files 6371 6371
Lines 576829 576838 +9
Branches 70627 70629 +2
============================================
- Hits 114778 114769 -9
- Misses 449507 449524 +17
- Partials 12544 12545 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Author
|
I came accross this while testing PR #13758 The authorized_keys file was wrong: The newline between the SSH keys wasn't correct. After this commit it now works as expected. |
Contributor
Author
|
To add, this is how meta_data.json looked in the incorrect format and the correct format: This PR has been tested in real-life with a Ubuntu 26.04 VM using ConfigDrive as it's cloud-init datasource. |
…tadata
An Instance with more than one SSH keypair gets its keys as a single
newline-joined string. The OpenStack meta_data.json builder passed that
string through as one key, so "keys" held a single object and
"public_keys" a single map entry whose value contained both keys with a
newline in between. cloud-init treats every public_keys value as one key
and never splits it, so only the first key worked at best. The name
derived from the third whitespace-separated token could also end up
containing a newline, and the replace("\\n", "") calls stripped a literal
backslash-n rather than a newline and did nothing.
The builder now splits the content on line breaks and emits one "keys"
object and one "public_keys" entry per key. A key is named after its
comment when it has one no earlier key used, otherwise "key" for a lone
key and key0, key1, ... when there are several.
wido
force-pushed
the
configdrive-multiple-ssh-keys
branch
from
September 15, 2026 09:58
b157e67 to
a08f069
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
An Instance with more than one SSH keypair receives its keys as one newline-joined string. The OpenStack
meta_data.jsonbuilder wrote that string as a single key:keysheld one object andpublic_keysone entry whose value contained both keys with a newline in between. cloud-init treats everypublic_keysvalue as one key and never splits it, so only the first key worked at best. Present since multiple SSH keys were introduced in 4.17 (#5965).The builder now emits one
keysobject and onepublic_keysentry per key. A key is named after its comment when it has one that no earlier key used, otherwisekeyfor a single key andkey0,key1, ... for several.Output for an Instance with two keys, the second one with a comment:
{ "keys": [ {"type": "ssh", "data": "ssh-ed25519 AAAA...bsP2", "name": "key0"}, {"type": "ssh", "data": "ssh-ed25519 AAAA...LOn user@laptop", "name": "user@laptop"} ], "public_keys": { "key0": "ssh-ed25519 AAAA...bsP2", "user@laptop": "ssh-ed25519 AAAA...LOn user@laptop" } }Types of changes
Feature/Enhancement Scale or Bug Severity
How Has This Been Tested?
Unit tests added to
ConfigDriveBuilderTestfor a single key, a key with a comment, two keys, duplicate comments with blank lines, and untouched other metadata. Observed on a KVM Instance with two keypairs:meta_data.jsonon the ConfigDrive had both keys in one string and cloud-init installed neither correctly.