Skip to content

Instantly share code, notes, and snippets.

@GregBrimble
Last active March 11, 2018 11:57
Show Gist options
  • Save GregBrimble/312e25c94cc77e6242833bdf2cbf78a7 to your computer and use it in GitHub Desktop.
Save GregBrimble/312e25c94cc77e6242833bdf2cbf78a7 to your computer and use it in GitHub Desktop.
SSH Permissions Fixer
echo "Hi, "$USER"! Welcome to the SSH permissions fixer."
echo "Fixing '~/.ssh' folder permissions..."
chmod -R 700 ~/.ssh
echo "Done."
echo "Fixing all keys (e.g. '~/.ssh/id_rsa') and their public components (e.g. '~/.ssh/id_rsa.pub')..."
chmod 600 ~/.ssh/* && chmod 644 ~/.ssh/*.pub
echo "Done."
echo "Fixing '~/.ssh/authorized_keys'..."
chmod 640 ~/.ssh/authorized_keys
echo "Done."
echo "Fixing '~/.ssh/known_hosts' and '~/.ssh/config'..."
chmod 700 ~/.ssh/known_hosts
echo "Done."
echo "Complete!"
echo "If there is still a problem, check the permissions of your home directory `~`. It should be at least 755."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment