Fix SSH key symlink creating nested .ssh directory#1098
Fix SSH key symlink creating nested .ssh directory#1098dfederm wants to merge 1 commit intohassio-addons:mainfrom
Conversation
Fixes hassio-addons#1066 When the init-user script runs, it creates a symlink from ~/.ssh to /data/.ssh (the persistent storage location). However, if ~/.ssh already exists as a real directory (not a symlink), the 'ln -sn' command places the symlink *inside* that directory, resulting in ~/.ssh/.ssh -> /data/.ssh instead of the intended ~/.ssh -> /data/.ssh. The -n flag only prevents following an existing symlink at the target; it does not prevent ln from placing the new link inside an existing real directory. This causes SSH authentication to fail because ssh looks for keys in ~/.ssh/ (the real directory) rather than in /data/.ssh/ where the keys actually reside. Users had to manually run 'ssh-add' or copy keys from ~/.ssh/.ssh/ back into ~/.ssh/ as a workaround. The fix removes ~/.ssh if it exists as a real directory (not a symlink) before creating the symlink. This ensures the symlink is always created correctly as ~/.ssh -> /data/.ssh regardless of prior state. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 WalkthroughAdds a pre-flight check to remove an existing non-symlink Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Gently paging @frenck |
|
@frenck ? |
|
This is a small change that fixes a bug which makes the add-on borderline unusable. |
|
this pr is currently failing a check. it needs a label added, such as "breaking-change, bugfix, documentation, enhancement, refactor, performance, new-feature, maintenance, ci, dependencies, translations" |
|
@EdeVriesCVE I don't have permissions to add a label to the PR as I'm not a maintainer of the repo. |
Fixes #1066
When the init-user script runs, it creates a symlink from
~/.sshto/data/.ssh(the persistent storage location). However, if~/.sshalready exists as a real directory (not a symlink), theln -sncommand places the symlink inside that directory, resulting in~/.ssh/.ssh -> /data/.sshinstead of the intended~/.ssh -> /data/.ssh. The-nflag only prevents following an existing symlink at the target; it does not prevent ln from placing the new link inside an existing real directory.This causes SSH authentication to fail because ssh looks for keys in
~/.ssh/(the real directory) rather than in/data/.ssh/where the keys actually reside. Users had to manually runssh-addor copy keys from~/.ssh/.ssh/back into~/.ssh/as a workaround.The fix removes
~/.sshif it exists as a real directory (not a symlink) before creating the symlink. This ensures the symlink is always created correctly as~/.ssh -> /data/.sshregardless of prior state.Summary by CodeRabbit