Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'reset password' cannot switch to the other authentication mode because of 50-cloud-init.conf #4335

Closed
ani-sinha opened this issue Aug 11, 2023 · 7 comments · Fixed by Azure/azure-linux-extensions#1774
Labels
bug Something isn't working correctly new An issue that still needs triage

Comments

@ani-sinha
Copy link
Contributor

Description of problem:
The Azure VM 'reset password' feature overrides the /etc/ssh/sshd_config file, which changes the PasswordAuthentication. From cloud-init v22.3, it writes 'PasswordAuthentication' in the /etc/ssh/sshd_config.d/50-cloud-init.conf, so that override 'sshd_config' file cannot reset the 'PasswordAuthentication' item.
For example, we use 'ssh key' method to create the Azure VM and cloud-init write 'PasswordAuthentication no' in 50-cloud-init.conf. Then we use 'reset password' to create a new user 'azuredebug' with "password" authentication. Then we still cannot use password authentication to ssh into the VM because the 'PasswordAuthentication no' in 50-cloud-init.conf has higher priority than it in 'sshd_config'.

Version-Release number of selected components (if applicable):
cloud-init-23.1.1-8.el9.noarch
Microsoft.OSTCExtensions.VMAccessForLinux-1.5.15 (This extension is used for resetting password)

How reproducible:
100%

Steps to Reproduce:
1 Create a VM on Azure that is provisioned by cloud-init, use 'ssh key' authentication method
2 Click on 'reset password' item in the Azure portal VM page, select 'Reset password' mode and create a new account 'azuredebug' and set password. Click on the 'Update' button on the top.
3. Wait for it to finish. Then try to ssh login the VM with 'azuredebug' user and password.

Actual results:
Cannot login with password.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

Expected results:
Can login with password

Additional info:
The "Microsoft.OSTCExtensions.VMAccessForLinux-1.5.15" is an Azure extension: https://github.com/Azure/azure-linux-extensions/blob/master/VMAccess/README.md

@ani-sinha ani-sinha added bug Something isn't working correctly new An issue that still needs triage labels Aug 11, 2023
@cjp256
Copy link
Contributor

cjp256 commented Aug 14, 2023

Looks like VMAccess supports this config for Ubuntu, but I expect other distro support is required? @norakoiralamsft

Azure/azure-linux-extensions#1635

@blackboxsw
Copy link
Collaborator

Looks like this is an el9 based system. @ani-sinha can you confirm the distributions/releases affected ? It looks like the linked fix was Ubuntu only and the azure-linux-extensions has awareness of centos, redhat and fedora. This doesn't really look like a cloud-init issue per-se, but an integration issue on Azure cloud with additional features.

@ani-sinha
Copy link
Contributor Author

ani-sinha commented Aug 15, 2023 via email

@ani-sinha
Copy link
Contributor Author

ani-sinha commented Aug 15, 2023 via email

@ani-sinha
Copy link
Contributor Author

Looks like this is an el9 based system. @ani-sinha can you confirm the distributions/releases affected ? It looks like the linked fix was Ubuntu only and the azure-linux-extensions has awareness of centos, redhat and fedora. This doesn't really look like a cloud-init issue per-se, but an integration issue on Azure cloud with additional features.

Yes @blackboxsw this is a centos/RHEL system.

ani-sinha added a commit to ani-sinha/azure-linux-extensions that referenced this issue Aug 16, 2023
Azure 'reset password' feature overrides the /etc/ssh/sshd_config file and sets
the PasswordAuthentication to 'yes'. Unfortunately, cloud-init versions 22.3 and
newer sets 'PasswordAuthentication' to 'no' in the
/etc/ssh/sshd_config.d/50-cloud-init.conf which overrides the setting in
/etc/ssh/sshd_config file. VMAccess handles this for Ubuntu by setting
PasswordAuthentication to 'yes' additionally in /etc/ssh/sshd_config.d/50-cloud-init.conf
file. This change extends the same method to include CentOS and RHEL systems.

Fixes: canonical/cloud-init#4335

Signed-off-by: Ani Sinha <anisinha@redhat.com>
@ani-sinha
Copy link
Contributor Author

I sent a PR: Azure/azure-linux-extensions#1774

ani-sinha added a commit to ani-sinha/azure-linux-extensions that referenced this issue Aug 16, 2023
Azure 'reset password' feature overrides the /etc/ssh/sshd_config file and sets
the PasswordAuthentication to 'yes'. Unfortunately, cloud-init versions 22.3 and
newer sets 'PasswordAuthentication' to 'no' in the
/etc/ssh/sshd_config.d/50-cloud-init.conf which overrides the setting in
/etc/ssh/sshd_config file. VMAccess handles this for Ubuntu by setting
PasswordAuthentication to 'yes' additionally in /etc/ssh/sshd_config.d/50-cloud-init.conf
file. This change extends the same method to include all OSes.

Fixes: canonical/cloud-init#4335

Signed-off-by: Ani Sinha <anisinha@redhat.com>
@holmanb
Copy link
Member

holmanb commented Aug 23, 2023

Since this issue represents a bug in a separate project that affects cloud-init behavior, I will close this issue to be tracked in azure-linux-extensions.

@holmanb holmanb closed this as completed Aug 23, 2023
jscalev pushed a commit to Azure/azure-linux-extensions that referenced this issue Sep 22, 2023
Azure 'reset password' feature overrides the /etc/ssh/sshd_config file and sets
the PasswordAuthentication to 'yes'. Unfortunately, cloud-init versions 22.3 and
newer sets 'PasswordAuthentication' to 'no' in the
/etc/ssh/sshd_config.d/50-cloud-init.conf which overrides the setting in
/etc/ssh/sshd_config file. VMAccess handles this for Ubuntu by setting
PasswordAuthentication to 'yes' additionally in /etc/ssh/sshd_config.d/50-cloud-init.conf
file. This change extends the same method to include all OSes.

Fixes: canonical/cloud-init#4335

Signed-off-by: Ani Sinha <anisinha@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly new An issue that still needs triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants