Skip to content

Commit 37bdf6d

Browse files
VMAccess: Add Azure Linux / Mariner support to _get_default_ssh_config_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
1 parent 4ccb560 commit 37bdf6d

2 files changed

Lines changed: 134 additions & 0 deletions

File tree

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# $OpenBSD: sshd_config,v 1.105 2024/12/03 14:12:47 dtucker Exp $
2+
3+
# This is the sshd server system-wide configuration file. See
4+
# sshd_config(5) for more information.
5+
6+
# This sshd was compiled with PATH=/usr/local/bin:/usr/bin
7+
8+
# The strategy used for options in the default sshd_config shipped with
9+
# OpenSSH is to specify options with their default value where
10+
# possible, but leave them commented. Uncommented options override the
11+
# default value.
12+
13+
# To modify the system-wide sshd configuration, create a *.conf file under
14+
# /etc/ssh/sshd_config.d/ which will be automatically included below
15+
Include /etc/ssh/sshd_config.d/*.conf
16+
17+
# If you want to change the port on a SELinux system, you have to tell
18+
# SELinux about this change.
19+
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
20+
#
21+
#Port 22
22+
#AddressFamily any
23+
#ListenAddress 0.0.0.0
24+
#ListenAddress ::
25+
26+
#HostKey /etc/ssh/ssh_host_rsa_key
27+
#HostKey /etc/ssh/ssh_host_ecdsa_key
28+
#HostKey /etc/ssh/ssh_host_ed25519_key
29+
30+
# Ciphers and keying
31+
#RekeyLimit default none
32+
33+
# Logging
34+
#SyslogFacility AUTH
35+
#LogLevel INFO
36+
37+
# Authentication:
38+
39+
#LoginGraceTime 2m
40+
#PermitRootLogin prohibit-password
41+
#StrictModes yes
42+
#MaxAuthTries 6
43+
#MaxSessions 10
44+
45+
#PubkeyAuthentication yes
46+
47+
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
48+
# but this is overridden so installations will only check .ssh/authorized_keys
49+
AuthorizedKeysFile .ssh/authorized_keys
50+
51+
#AuthorizedPrincipalsFile none
52+
53+
#AuthorizedKeysCommand none
54+
#AuthorizedKeysCommandUser nobody
55+
56+
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
57+
#HostbasedAuthentication no
58+
# Change to yes if you don't trust ~/.ssh/known_hosts for
59+
# HostbasedAuthentication
60+
#IgnoreUserKnownHosts no
61+
# Don't read the user's ~/.rhosts and ~/.shosts files
62+
#IgnoreRhosts yes
63+
64+
# To disable tunneled clear text passwords, change to "no" here!
65+
#PasswordAuthentication yes
66+
#PermitEmptyPasswords no
67+
68+
# Change to "no" to disable keyboard-interactive authentication. Depending on
69+
# the system's configuration, this may involve passwords, challenge-response,
70+
# one-time passwords or some combination of these and other methods.
71+
#KbdInteractiveAuthentication yes
72+
73+
# Kerberos options
74+
#KerberosAuthentication no
75+
#KerberosOrLocalPasswd yes
76+
#KerberosTicketCleanup yes
77+
#KerberosGetAFSToken no
78+
#KerberosUseKuserok yes
79+
80+
# GSSAPI options
81+
#GSSAPIAuthentication no
82+
#GSSAPICleanupCredentials yes
83+
#GSSAPIStrictAcceptorCheck yes
84+
#GSSAPIKeyExchange no
85+
#GSSAPIEnablek5users no
86+
87+
# Set this to 'yes' to enable PAM authentication, account processing,
88+
# and session processing. If this is enabled, PAM authentication will
89+
# be allowed through the KbdInteractiveAuthentication and
90+
# PasswordAuthentication. Depending on your PAM configuration,
91+
# PAM authentication via KbdInteractiveAuthentication may bypass
92+
# the setting of "PermitRootLogin prohibit-password".
93+
# If you just want the PAM account and session checks to run without
94+
# PAM authentication, then enable this but set PasswordAuthentication
95+
# and KbdInteractiveAuthentication to 'no'.
96+
# WARNING: 'UsePAM no' is not supported in this build and may cause several
97+
# problems.
98+
#UsePAM no
99+
100+
#AllowAgentForwarding yes
101+
#AllowTcpForwarding yes
102+
#GatewayPorts no
103+
#X11Forwarding no
104+
#X11DisplayOffset 10
105+
#X11UseLocalhost yes
106+
#PermitTTY yes
107+
#PrintMotd yes
108+
#PrintLastLog yes
109+
#TCPKeepAlive yes
110+
#PermitUserEnvironment no
111+
#Compression delayed
112+
#ClientAliveInterval 0
113+
#ClientAliveCountMax 3
114+
#UseDNS no
115+
#PidFile /var/run/sshd.pid
116+
#MaxStartups 10:30:100
117+
#PermitTunnel no
118+
#ChrootDirectory none
119+
#VersionAddendum none
120+
121+
# no default banner path
122+
#Banner none
123+
124+
# override default of no subsystems
125+
Subsystem sftp /usr/libexec/openssh/sftp-server
126+
127+
# Example of overriding settings on a per-user basis
128+
#Match User anoncvs
129+
# X11Forwarding no
130+
# AllowTcpForwarding no
131+
# PermitTTY no
132+
# ForceCommand cvs server

VMAccess/vmaccess.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ def _get_default_ssh_config_filename():
392392
return "debian_default"
393393
if re.search("fedora", OSName, re.IGNORECASE):
394394
return "fedora_default"
395+
if re.search("azure\s?linux|mariner", OSName, re.IGNORECASE):
396+
return "azurelinux_default"
395397
if re.search("red\s?hat", OSName, re.IGNORECASE):
396398
return "redhat_default"
397399
if re.search("suse", OSName, re.IGNORECASE):

0 commit comments

Comments
 (0)