-
Notifications
You must be signed in to change notification settings - Fork 384
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. |
…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.
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. |
CI integration ❌ failed! 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: