[master] core: services: commander: Keep .ssh keys on settings reset - #4122
Conversation
Reset Settings wiped /root/.config/.ssh, which holds the keypair used to run commands on the host. Without it every host command falls back to sshpass with the default password, breaking every commander feature on vehicles where that password was changed.
Automated PR Review0. Summary
Adds No further comments, nice job 👍 Generated by PR Review Bot. This is advisory, a human reviewer must still approve. |
Fixes #3440 for master
Master counterpart of #4120. Master already has #3677, so the only missing piece here is the
.sshentry.Problem
Reset Settingsdeletes everything under/root/.config, including/root/.config/.ssh— the keypair commander uses to run commands on the host. Once it is gone,run_command()falls back tosshpasswith the default password (SSH_USER/SSH_PASSWORD), so every commander-backed feature breaks on any vehicle where the default password was changed, and a reboot does not recover it.The reset already protects
ardupilot-manager,bag-of-holding,bootstrapandkrakenfor the same reason (#3677);.sshwas simply never added to that list.Changes
/root/.config/.sshto thereset_settingsignore list.Preserving is used instead of regenerating so the key is never absent, and the private key never has to be copied through
/tmp. The public half in/home/pi/.ssh/authorized_keyswas never removed by reset anyway, so deleting the private key only ever broke auth while leaving a stale entry behind.Complements #3898, which adds the recovery path (
setup_ssh()on startup) — this PR stops the key from being destroyed in the first place.Test plan
The
ignoremechanism is already covered bytest_delete_everythingandtest_delete_everything_single_file, so this change adds no tests.Behaviour was verified on a Raspberry Pi running
1.4.4-beta.15via #4120, whosereset_settingsis identical to this one after the backport:POST /commander/v1.0/settings/resetleaves/root/.config/.sshempty, and the next host command logsFailed to run command with SSH key ... trying with sshpassssh -i /root/.config/.ssh/id_rsa(no fallback)/root/.config/beaconis deleted, while markers under the ignored directories survive./.hooks/pre-pushpasses