Skip to content

Instantly share code, notes, and snippets.

@JTRNS
Created March 13, 2021 18:59
Show Gist options
  • Save JTRNS/65d3b7e3a0ed23e05352d16cc59b7fbe to your computer and use it in GitHub Desktop.
Save JTRNS/65d3b7e3a0ed23e05352d16cc59b7fbe to your computer and use it in GitHub Desktop.
ssh permissions fix
#!/usr/bin/env bash
echo "fixing permissions for ssh"
# rwx --- ---
chmod 700 $HOME/.ssh
# if it is not a public key, -rw --- --- (inc. conf, auth_hosts)
find $HOME/.ssh -type f ! -name "*.pub" -print0 | xargs -0 chmod 600
# -rw r-- r--
find $HOME/.ssh -type f -name "*.pub" -print0 | xargs -0 chmod 644
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment