backends: LXD: fix SSH login for ubuntu-22.04#179
backends: LXD: fix SSH login for ubuntu-22.04#179thp-canonical wants to merge 2 commits intocanonical:masterfrom
Conversation
|
Related issue in other backends, probably we should align with those: |
b0438af to
c6220b5
Compare
c6220b5 to
3954505
Compare
|
I'm interested in this fix. It sounds like it could fix the spread test issue we're seeing in Netplan's CI: |
There was a problem hiding this comment.
Thank you for catching this, Maybe let's wait for the fix to be merged in the google backend #155? and then backport it to all other providers so that the fix is consistent across all of them.
ZeyadYasser
left a comment
There was a problem hiding this comment.
Thanks a lot for the fix, just a small nitpick
Co-authored-by: Zeyad Yasser <[email protected]>
|
Hi, Thanks! |
| func (p *lxdProvider) tuneSSH(name string) error { | ||
| cmds := [][]string{ | ||
| {"sed", "-i", `s/^\s*#\?\s*\(PermitRootLogin\|PasswordAuthentication\)\>.*/\1 yes/`, "/etc/ssh/sshd_config"}, | ||
| {"/bin/bash", "-c", `sed -i 's/^\s*\(PermitRootLogin\|PasswordAuthentication\)\>.*/# COMMENTED OUT BY SPREAD: \0/' /etc/ssh/sshd_config.d/* || true`}, |
There was a problem hiding this comment.
The SSH daemon uses the first value it finds for a given configuration entry if it appears multiple times, so just adding the 00 line below should be enough?
|
Superseded by #184 |
This fixes the issue that SSH login wouldn't work after a ubuntu-22.04 image is deployed.
While
tuneSSH()tries to setPasswordAuthenticationtoyesin/etc/ssh/sshd_config, Ubuntu 22.04 images in LXD have a file/etc/ssh/sshd_config.d/60-cloudimg-settings.confthat contains "PasswordAuthentication no", and this file is sourced by/etc/ssh/sshd_config.Fix this by also
seding all files matching/etc/ssh/sshd_config.d/*, but ignore failures of this command, as Ubuntu 20.04 and older don't have/etc/ssh/sshd_config.d(or files that match the glob above).Related links: https://superuser.com/a/1828947