Skip to content

VMAccess: Add Azure Linux / Mariner support to sshd_config reset#2174

Open
jonathanbrenes wants to merge 2 commits into
Azure:masterfrom
jonathanbrenes:fix/vmaccess-azurelinux-sshd-config
Open

VMAccess: Add Azure Linux / Mariner support to sshd_config reset#2174
jonathanbrenes wants to merge 2 commits into
Azure:masterfrom
jonathanbrenes:fix/vmaccess-azurelinux-sshd-config

Conversation

@jonathanbrenes

Copy link
Copy Markdown

Problem

As preparation for the release of Azure Linux 4.0, this patch adds support for Azure Linux and CBL-Mariner to the VMAccess extension's sshd_config reset functionality.

When az vm user reset-ssh is triggered on Azure Linux (or CBL-Mariner), _get_default_ssh_config_filename() falls through to the generic default resource file because NAME="Azure Linux" does not match any of the existing distro regexes (centos, debian, fedora, red hat, suse, ubuntu).

The default resource file is a Debian/Ubuntu-era sshd_config that causes the following problems on Azure Linux:

  • SFTP broken: wrong Subsystem path (/usr/lib/openssh/sftp-server instead of /usr/libexec/openssh/sftp-server)
  • Multiple deprecated directive warnings from sshd -t
  • Unable to load host key: /etc/ssh/ssh_host_dsa_key (DSA removed)
  • Include directive dropped: Include /etc/ssh/sshd_config.d/*.conf removed, causing all drop-in config snippets (cloud-init, Azure) to be silently lost
  • PasswordAuthentication explicitly set to yes
  • PermitRootLogin uses old without-password syntax

Fix

  1. Added azure\s?linux|mariner regex to _get_default_ssh_config_filename() returning azurelinux_default. This matches:

    • Azure Linux: NAME="Azure Linux"
    • CBL-Mariner: NAME="Common Base Linux Mariner"
  2. Added VMAccess/resources/azurelinux_default: stock Azure Linux sshd_config with no deprecated directives, correct SFTP path, and Include directive preserved.

Testing

Tested on an Azure Linux VM:

Check Before (default) After (azurelinux_default)
sshd -t errors 6 warnings/errors 0
SFTP Subsystem path /usr/lib/openssh/sftp-server (wrong) /usr/libexec/openssh/sftp-server (correct)
Include directive Missing Present
DSA host key reference Present (file doesn't exist) Absent
PasswordAuthentication yes Commented out (default: no)
sshd restart Clean (after warnings) Clean

Files Changed

  • VMAccess/vmaccess.py — added Azure Linux / Mariner match in _get_default_ssh_config_filename()
  • VMAccess/resources/azurelinux_default — new sshd_config template for Azure Linux

@jonathanbrenes
jonathanbrenes requested review from a team, D1v38om83r and nkuchta as code owners May 19, 2026 19:29
@birukyitbarek

Copy link
Copy Markdown
Contributor

See merge conflict. Branch is behind master. After rebase the raw-string convention will be obvious.

@jonathanbrenes
jonathanbrenes force-pushed the fix/vmaccess-azurelinux-sshd-config branch from 37bdf6d to 70d7d75 Compare July 23, 2026 15:19
…g_filename

As preparation for the release of Azure Linux 4.0, this patch adds
support for Azure Linux and CBL-Mariner to the VMAccess extension's
sshd_config reset functionality.

When 'az vm user reset-ssh' is triggered on Azure Linux (or
CBL-Mariner), _get_default_ssh_config_filename() falls through to the
generic 'default' resource file because NAME="Azure Linux" does not
match any of the existing distro regexes (centos, debian, fedora,
red hat, suse, ubuntu).

The 'default' resource file is a Debian/Ubuntu-era sshd_config that
causes the following problems on Azure Linux:

- SFTP broken: wrong Subsystem path (/usr/lib/openssh/sftp-server
  instead of /usr/libexec/openssh/sftp-server)
- Multiple deprecated directive warnings from sshd -t
- Unable to load host key: /etc/ssh/ssh_host_dsa_key (DSA removed)
- Include /etc/ssh/sshd_config.d/*.conf directive dropped, causing
  all sshd_config.d snippets (cloud-init, Azure) to be silently lost
- PasswordAuthentication explicitly set to yes
- PermitRootLogin uses old 'without-password' syntax

Changes:
1. Add 'azure\s?linux|mariner' regex to _get_default_ssh_config_filename()
   returning 'azurelinux_default'. This matches:
   - Azure Linux: NAME="Azure Linux"
   - CBL-Mariner: NAME="Common Base Linux Mariner"

2. Add resources/azurelinux_default: stock Azure Linux sshd_config.
   Clean config with no deprecated directives, correct SFTP path,
   and Include directive preserved.

Tested on an Azure Linux VM:
- sshd -t: 0 errors (vs 6 with 'default')
- SFTP Subsystem: /usr/libexec/openssh/sftp-server (correct)
- Include /etc/ssh/sshd_config.d/*.conf: preserved
- sshd restart: clean
@jonathanbrenes
jonathanbrenes force-pushed the fix/vmaccess-azurelinux-sshd-config branch from 70d7d75 to d567ed5 Compare July 23, 2026 15:45
Comment thread VMAccess/vmaccess.py Outdated
if re.search("fedora", OSName, re.IGNORECASE):
return "fedora_default"
if re.search(r"azure\s?linux|mariner", OSName, re.IGNORECASE):
return "fedora_default"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should reurn azurelinux_default

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, you are right.

I verified the OS detection path and on Azure Linux the detected OS name is "Azure Linux", so this branch is hit. Returning fedora_default there is not what we want for the Azure Linux-specific template path.

I updated azurelinux_default so the dedicated Azure Linux sshd baseline is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants