-
Notifications
You must be signed in to change notification settings - Fork 59
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
backends: LXD: fix SSH login for ubuntu-22.04 #179
backends: LXD: fix SSH login for ubuntu-22.04 #179
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the fix, just a small nitpick
Co-authored-by: Zeyad Yasser <zeyady98@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Thank you!
Hi, Thanks! |
@@ -482,6 +482,8 @@ func (p *lxdProvider) serverJSON(name string) (*lxdServerJSON, error) { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 setPasswordAuthentication
toyes
in/etc/ssh/sshd_config
, Ubuntu 22.04 images in LXD have a file/etc/ssh/sshd_config.d/60-cloudimg-settings.conf
that contains "PasswordAuthentication no", and this file is sourced by/etc/ssh/sshd_config
.Fix this by also
sed
ing 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