canonical / canonical/cloud-init
cc_ssh: parse_ssh_config_map does not take into account user-specific Match section overrides
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 1.1k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 18
Description
This bug was originally filed in Launchpad as [LP: #1935857](https://bugs.launchpad.net/cloud-init/+bug/1935857)
Launchpad details
affected_projects = []
assignee = None
assignee_name = None
date_closed = None
date_created = 2021-07-12T17:55:13.369080+00:00
date_fix_committed = None
date_fix_released = None
id = 1935857
importance = low
is_complete = False
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1935857
milestone = None
owner = chad.smith
owner_name = Chad Smith
private = False
status = triaged
submitter = chad.smith
submitter_name = Chad Smith
tags = []
duplicates = []
_Launchpad user **Chad Smith(chad.smith)** wrote on 2021-07-12T17:55:13.369080+00:00_
cloud-init 21.2
User-specific Match sections can be provided in /etc/ssh/sshd_config to override global ssh config default settings such as AuthorizedKeysFile.
cloud-init's parsing of sshd_config in ssh_util[1] is simplistic and treats each line in the sshd_config file as simple key/value pairs. Any Match sections defined below a global AuthorizedKeysFile setting will be overridden to the line containing an AuthorizedKeysFile definition, even if that definition should only be scoped to a specific user Match.
Here is an example adding a specific Match section which should only apply non-default AuthorizedKeysFile to the "custom" user, and how cloud-init incorrectly represents that content.
$ cat sshd_bad_parse.yaml <
Contributor guide
Assessment
This issue has not been assessed yet.