-
Notifications
You must be signed in to change notification settings - Fork 389
image: T5455: Add migration of SSH known_hosts
files during upgrade
#4678
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
base: current
Are you sure you want to change the base?
Conversation
👍 |
known_hosts
files during image upgradeknown_hosts
files during upgrade
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.
Pull Request Overview
This PR adds functionality to migrate SSH known_hosts
files during VyOS system image upgrades. The migration preserves SSH fingerprints from the current configuration to the new image, preventing the need to re-verify SSH connections after upgrade.
- Implements detection and migration of
known_hosts
files for root and all users - Adds user prompts during upgrade to confirm migration of SSH known hosts
- Integrates the migration process into the existing image installation workflow
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
f45e502
to
7b044a3
Compare
7b044a3
to
7583c64
Compare
Other then the tree minor changes in placing imports on their own line - code looks good. |
7583c64
to
3aa7629
Compare
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.
All requested changes added. Change looks good.
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.
I see one problem with this: by implicitly creating the home directories in the persistence directory
/usr/lib/live/mount/persistence/boot/my-new-image-name/rw
during add system image, the useradd
in system_login.py
on first boot into the new image will avoid copying skeleton files. The warning is not recorded, but an analogous situation is, say:
vyos@vyos:~$ sudo mkdir /home/bob
vyos@vyos:~$ sudo useradd --create-home --home /home/bob bob
useradd: warning: the home directory /home/bob already exists.
useradd: Not copying any file from skel directory into it.
The result in my test is that, on booting into the new image, one sees:
vyos@vyos:~$ show version
Invalid command: [show]
vyos@vyos:~$ pwd
/home/vyos
vyos@vyos:~$ ls -la
total 16
drwxr-xr-x 3 vyos root 4096 Aug 29 17:56 .
drwxr-xr-x 1 root root 4096 Aug 29 17:41 ..
-rw------- 1 vyos users 224 Aug 29 17:56 .bash_history
drwxr-xr-x 2 vyos root 4096 Aug 29 17:47 .ssh
-rw-r--r-- 1 vyos users 0 Aug 29 17:47 .sudo_as_admin_successful
so, no .bashrc etc, hence no completions.
Updating the image with this PR but without copying the known_hosts
files returns normal behavior in the new image.
So, I don't have a concrete suggestion yet, but do want to point out the issue.
@jestabro thanks for finding this because I missed it. I will prepare fix for this PR. |
3aa7629
to
7f5ad80
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
7f5ad80
to
62c643b
Compare
Fix: Preserve existing home directory when adding user by backing up and restoring its contents after |
Conflicts have been resolved. A maintainer will review the pull request shortly. |
Re-running failed jobs, as a check; all passed in a local test. Review pending. |
The current version exposes an interesting issue (not directly related to the PR), as well as having a critical issue itself --- on a system with the PR, before any upgrade, one has (with my added 'DEBUG print' lines):
(1) cd'ing away from the directory and back will find expected files |
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.
Cf. comment above
62c643b
to
4a5212d
Compare
4a5212d
to
eb146e1
Compare
I've simplified the approach to saving user's files a bit. I'm not sure about naming of temporary directory ( |
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.
Simple tests of upgrade now pass.
@c-po could you look at this PR again because I have changed the original approach. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
eb146e1
to
e83817a
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
e83817a
to
69759cc
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
69759cc
to
16a1a23
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
…pgrade During upgrade, the script now checks if any `known_hosts` files exist. If so, it prompts the user to save these SSH fingerprints, and upon confirmation, copies the files to the new image persistence directory.
16a1a23
to
6b6f75e
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
CI integration 👍 passed! Details
|
Change summary
During upgrade, the script now checks if any
known_hosts
files exist. If so, it prompts the user to save these SSH fingerprints, and upon confirmation, copies the files to the new image persistence directory.Types of changes
Related Task(s)
How to test / Smoketest result
Ensure
known_hosts
files exist for root or users, then run the upgrade and confirm you’re prompted to migrate them. After choosing Yes, verify the files are copied; with No or no files, they should not be migrated or prompted.Checklist: