1

I've been through quite a few rounds of this over the years:

  1. Someone gives me their id_rsa.pub
  2. I copy it into .ssh/authorized_keys
  3. I ask them to test
  4. Some time later, they test and report it doesn't work.
  5. I mess around with line feeds, permissions etc, go back to step 3.

Is there any way (obviously without asking for their private key) to verify that a public key has been installed correctly?

-1

TROUBLESHOOTING

On your remote server, run the following:

ls -la ~/.ssh | grep "authorized_keys"

You should see output similar to the following:

-rw-------  1 example.com example.com 398 Jul 15 10:32 authorized_keys

Note that the directory needs to include the file called authorized_keys with -rw------- (600) permissions.

Finally, run this command to check the permissions on your .ssh directory:

$ ls -ld ~/.ssh
drwx------   2 example.com example.com     3 Jul 15 10:32 .ssh

You should have a folder called .ssh with drwx------ (700) permissions.

If for either of these tests, you get blank output, or a message similar to the following:

ls: /root/.ssh: No such file or directory

Please repeat Steps 1 and 4-5 above.

Found this here

3
  • No, .ssh and authorized_keys can be world-readable. See man ssh, section FILES. Those permissions are merely recommended, not required. – muru Feb 9 '17 at 1:39
  • I have never tried it, perhaps you can log in to your client with the key, then ssh back to your server? Just throwing that out there. (Of course if you could do that, then you would have access to the Private key. :)) – EODCraft Staff Feb 9 '17 at 11:39
  • What @muru said, and why grep ls output instead of just using ls -la ~/.ssh/authorized_keys ? Anyways, the simple presence of these file does not really mean that the keys were installed correctly. – pLumo Nov 13 '20 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.