-
Notifications
You must be signed in to change notification settings - Fork 97
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
Kairos user ids change on upgrade, breaking ssh login #2797
Comments
It's because of this change: mudler/entities#15 The id 65535 which we were assigning, according to systemd is the "nobody" user. This was creating some bug with some service not being started or something. Unfortunately I can't find a link back to the original problem (I always add links between issues and fixes in various repos but I missed it here). @kairos-io/maintainers does anyone remember what problem this was causing? In any case, the id we assign now is correct but I don't think we predicted the home directory change. |
I just got bit by this too. Luckily I had local access to the box with a password so I could fix the permissions so I could ssh again. |
As a workaround, you can add this to your config to make sure when you apply the 3.1.0 upgrade you don't lose ssh access: fs:
- name: Ensure kairos owns files in its user directory
commands:
- chown -R kairos:kairos ~kairos |
The issue comes because now we ignore the nobody user when calculating the UID so we don't get those absurd high uids anymore. And unfortunately in existing installs this will hit. Unfortunately this will affect all upgrades either with Kairos user or not :( Because the files are persistent but the user is not, the files will always have a different user id after upgrade. No idea how we can workaround this for all users easily. I'll add a note in the release notes and send a comment in the channel about this. Thanks for the report @robarnold and the workaround @sdwilsh ! |
Yeah, I run a lot of my pods with the nobody user, not realizing it was going to be having the same permissions as the kairos user, so I'm happy for the change! It was just a surprise to lose access over ssh. |
we could probably add a yip config file that runs in
In order to refix the home directories |
This works around kairos-io/kairos#2797
I'm assuming this would impact kairos 3.0.x |
I reproduced locally. I will now try a fix (starting with Itxaka's proposal). |
I created an upgrade image with this Dockerfile:
and it kind of works:
The home directory and some of the contents (e.g. |
Never mind, |
All fine now:
I'll prepare a PR for the packages repo |
Fixes kairos-io/kairos#2797 Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
Fixes kairos-io/kairos#2797 Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
Hate to say this, but this issue has not been fixed 😞 After upgrading to janitor@localhost:~$ ls -liahR .
.:
total 16K
43385501 drwxr-xr-x 3 janitor janitor 4.0K Sep 9 05:14 .
43384860 drwxr-xr-x 4 root root 4.0K Mar 29 17:20 ..
43385509 -rw------- 1 65536 65536 131 Sep 9 05:15 .bash_history
43385502 drwx------ 2 janitor janitor 4.0K Sep 9 04:31 .ssh
43385510 -rw-r--r-- 1 65536 65536 0 Sep 9 05:14 .sudo_as_admin_successful
./.ssh:
total 12K
43385502 drwx------ 2 janitor janitor 4.0K Sep 9 04:31 .
43385501 drwxr-xr-x 3 janitor janitor 4.0K Sep 9 05:14 ..
43385503 -rw------- 1 65536 65536 81 Sep 9 04:31 authorized_keys Curiously, for the kairos@localhost:~$ ls -liahR .
.:
total 16K
43385422 drwxr-xr-x 3 kairos kairos 4.0K Sep 9 05:52 .
43384860 drwxr-xr-x 4 root root 4.0K Mar 29 17:20 ..
43385535 -rw------- 1 kairos kairos 150 Sep 9 05:52 .bash_history
43385524 drwx------ 2 kairos kairos 4.0K Sep 9 05:43 .ssh
43385533 -rw-r--r-- 1 kairos kairos 0 Sep 9 05:44 .sudo_as_admin_successful
./.ssh:
total 8.0K
43385524 drwx------ 2 kairos kairos 4.0K Sep 9 05:43 .
43385422 drwxr-xr-x 3 kairos kairos 4.0K Sep 9 05:52 .. Note how If I run the snippet that is supposed to have fixed this (as the Changing ownership of /home/kairos to kairos
Changing ownership of /home/janitor to janitor
chown: changing ownership of '/home/janitor/.bash_history': Operation not permitted
chown: cannot read directory '/home/janitor/.ssh': Permission denied
chown: changing ownership of '/home/janitor/.sudo_as_admin_successful': Operation not permitted
chown: changing ownership of '/home/janitor': Operation not permitted Wondering whether that snippet ran with sufficient privileges to Anyway, I |
@paddy-hack thanks for letting us know. I think the logs would appear in |
Thanks for the pointer. Just took a peek and here's the scoop 2024-09-09T06:38:09Z INF Running stage: initramfs.after
2024-09-09T06:38:09Z INF Processing stage step 'Fix permissions'. ( commands: 1, files: 0, ... )
2024-09-09T06:38:09Z WRN (conditional) Skip 'Skipping stage (if statement error: failed to run [ -e /sbin/openrc ]: exit status 1)' stage name: Enable serial login for alpine
2024-09-09T06:38:09Z INF Command output: Changing ownership of /home/kairos to kairos
2024-09-09T06:38:09Z WRN (conditional) Skip 'Skipping stage (if statement error: failed to run [[ $(kairos-agent state get kairos.flavor) =~ ^ubuntu ]]: exit status 127)' stage name: setupcon initramfs.after ubuntu
2024-09-09T06:38:09Z INF Done executing stage 'initramfs.after' Makes me think custom user accounts are created after this step. |
If a user is created in a later stage, indeed, this wont work as expected. I know that wiht the interactive installer, the user is created in the network stage IF the user has an ssh key attached from github (as we need network to get it) so we may need to move this workaround into the boot stage maybe AND the network stage both :( |
FTR, my custom user's account was configured during installation with a literal public SSH key. No need for network to create the account. |
We opted for the |
Kairos version, CPU architecture, OS, and Version:
I am upgrading from
quay.io/kairos/ubuntu:23.10-standard-amd64-generic-v3.0.11-k3sv1.29.3-k3s1
toquay.io/kairos/ubuntu:24.04-standard-amd64-generic-v3.1.1-k3sv1.30.2-k3s1
Describe the bug
After login, I am unable to ssh into the new box with ssh keys. I am able to ssh in with password authentication.
To Reproduce
Do the aforementioned upgrade
Expected behavior
The kairos UID does not change during upgrades
Logs
Pre-upgrade, I see this when running
id
:Post-upgrade, I see this when running
id
:The files in the home directory retain the pre-upgrade user/group ownership for important things like
.ssh/authorized_keys
, which causessshd
to ignore this configuration.My kairos config does not set a uid/gid for the kairos user, only
passwd
andssh_authorized_keys
The text was updated successfully, but these errors were encountered: