canonical / spread

Spread - Convenient full-system test (task) distribution
GNU General Public License v3.0
101 stars 58 forks source link

backends: LXD: fix SSH login for ubuntu-22.04 #179

Open thp-canonical opened 9 months ago

thp-canonical commented 9 months ago

This fixes the issue that SSH login wouldn't work after a ubuntu-22.04 image is deployed.

While tuneSSH() tries to set PasswordAuthentication to yes 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 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

thp-canonical commented 9 months ago

Related issue in other backends, probably we should align with those:

slyon commented 8 months ago

I'm interested in this fix. It sounds like it could fix the spread test issue we're seeing in Netplan's CI:

Run ~/go/bin/spread -v lxd:
202[4](https://github.com/canonical/netplan/actions/runs/8265397396/job/22610944314#step:5:5)-03-13 13:22:3[5](https://github.com/canonical/netplan/actions/runs/8265397396/job/22610944314#step:5:6) Found /home/runner/work/netplan/netplan/spread.yaml.
2024-03-13 13:22:35 Project content is packed for delivery (1.01MB).
2024-03-13 13:22:35 Sequence of jobs produced with -seed=171033[6](https://github.com/canonical/netplan/actions/runs/8265397396/job/22610944314#step:5:7)155
2024-03-13 13:22:35 If killed, discard servers with: spread -reuse-pid=4596 -discard
2024-03-13 13:22:35 Allocating lxd:ubuntu-22.04...
2024-03-13 13:22:3[7](https://github.com/canonical/netplan/actions/runs/8265397396/job/22610944314#step:5:8) Cannot find cached LXD image for lxd:ubuntu-22.04.
2024-03-13 13:23:03 Waiting for lxd container spread-1-ubuntu-22-04 to have an address...
2024-03-13 13:23:05 Allocated lxd:ubuntu-22.04 (spread-1-ubuntu-22-04).
2024-03-13 13:23:05 Connecting to lxd:ubuntu-22.04 (spread-1-ubuntu-22-04)...
2024-03-13 13:24:05 Discarding lxd:ubuntu-22.04 (spread-1-ubuntu-22-04), cannot connect: cannot connect to lxd:ubuntu-22.04 (spread-1-ubuntu-22-04): ssh: handshake failed: ssh: unable to authenticate, attempted methods [none], no supported methods remain
2024-03-13 13:24:0[8](https://github.com/canonical/netplan/actions/runs/8265397396/job/22610944314#step:5:9) Successful tasks: 0
error: unsuccessful run
2024-03-[13](https://github.com/canonical/netplan/actions/runs/8265397396/job/22610944314#step:5:14) 13:24:08 Aborted tasks: 2
Error: Process completed with exit code 1.
verterok commented 4 months ago

Hi, This is affecting me and my team too. any chance to get this landed?

Thanks!