Created
December 3, 2022 05:21
-
-
Save DennisGentry-Zoetis/6530c75d9dcd7a5144623b1f4a366135 to your computer and use it in GitHub Desktop.
If an ssh server is rejecting your keys, run this on the server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
chown -R $USER ~/.ssh | |
chmod 700 ~/.ssh | |
chmod 600 ~/.ssh/authorized_keys | |
chmod 600 ~/.ssh/config | |
# This unnecessarily closes permissions on .pub keys too, but whatever | |
chmod 600 ~/.ssh/id_* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can debug a bit about what's going on with an ssh attempt using
-v
as inssh -v [email protected],
but it can still be difficult to tell why a remote server is rejecting your key. Usually you need to enable debugging from the ssh server to see what's going on, but also usually, the problem is that the ssh server is unhappy about some aspect of the permissions or ownership of one of the above-listed files. The above commands will make the problem not be permissions of your .ssh directory, config file, or authorized_keys file.