Skip to content

Ensure correct permissions for ~/.ssh/config #34

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

Closed
wants to merge 1 commit into from

Conversation

rikusilvola
Copy link

This patch automates setting the correct file permissions of the ssh client configuration file, which might otherwise be too permissive, should it already exist.

This bug only occurs when the config file exists, and has incorrect permissions, thus requiring changing them with chmod.

This PR replaces the prior #32 which was made to the wrong branch.

@dolmen
Copy link
Owner

dolmen commented Dec 10, 2016

Rejecting. See #32.

@dolmen dolmen closed this Dec 10, 2016
@rikusilvola
Copy link
Author

rikusilvola commented Dec 10, 2016

@dolmen, I do see what you mean. github-keygen should not force more restrictive permissions than what are required by ssh. I do however feel that github-keygen should make it easy for people to set up github keys, including correcting the file permissions, if they are too permissive, to the point that ssh will not accept them. I propose making a slight change to the PR with, checking the current rights and only changing them to the loosest acceptable mode (0660?) should they be too permissive.

@dolmen
Copy link
Owner

dolmen commented Dec 10, 2016

Your patch is about ~/.ssh/config, not about the key files.

Then I would prefer to report a "too wide permission" issue as a fatal error (with a fix suggestion) rather than silently "fixing" the issue. Your patch is just breaking the promise of transparency I made to the users. This is important to keep users' trust.

@rikusilvola
Copy link
Author

rikusilvola commented Dec 14, 2016

Quite true, but ssh puts restrictions on the allowed permissions of the config file too. The config file must not be writable to anyone but owner, lest ssh returns 255 and spits out Bad owner or permissions on ~/.ssh/config.

I suggest that instead of setting the full mode, the patch instead just strips off write access from others and group, thus retaining the permissions otherwise.

e.g.

    # strip [g]roup and [o]thers write access
    my $mode = (stat SSH_CONFIG_FILE)[2] & 07755;
    chmod $mode, SSH_CONFIG_FILE;

dolmen added a commit that referenced this pull request Dec 15, 2016
Detect bad permissions and fail, with a fix suggestion.
Contrary to pull requests #32, #34 we do not silently fix the issue
because:
- that is not our responsability: if the user did a bad thing he should
  be aware of it and be empowered to fix it.
- to keep user trust doing things silently is forbidden by our policy.
@dolmen
Copy link
Owner

dolmen commented Dec 15, 2016

I suggest that instead of setting the full mode, the patch instead just strips off write access from others and group [...]

As I already wrote above, my policy on this project is to not do things silently. So this patch is still not acceptable.
I have instead committed fd4d9f7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants