I can't add my ssh public key to the ssh-agent and my ssh folder is odd I believe.here is a screenshot

  • What is the output from ls -lad /home/maydara/.ssh /home/maydata and id – mdpc Dec 5 '18 at 1:09
  • @mdpc drwxr-xr-x 38 maydara maydara 4096 Dec 5 02:20 /home/maydara drw------- 2 maydara maydara 4096 Dec 5 00:54 /home/maydara/.ssh – Getsuga Dec 5 '18 at 1:21

The fix is chmod 700 /home/maydara/.ssh

Without the 'x' permission, a directory cannot be searched (i.e. files in directory cannot be found).

Edit: Also it might be necessary to change the owner of the .ssh directory and authorized_key file if they've been originally created with root.

chown -R maydara:maydara /home/maydara/.ssh
  • @Mbpc i've tried this before i wrote this post and it didn't work, I ended up deleting the whole folder and the keys then I started from scratch. – Getsuga Dec 5 '18 at 20:21
  • @Getsuga You might like to add that as an answer. :-) – Kulfy Dec 8 '18 at 8:39
  • @Kulfy thx for the suggestion but what i've done is not really a fix, it's a rebuild from scratch and that won't be helpful for people who don't have copies of their ssh keys. – Getsuga Dec 8 '18 at 21:42
  • @Getsuga Answer section is meant for posting things which solved the problem. I've seen many a times people do post a re-installation as their answer (since they solved their problem by re-installation). Your solution might help those who have copies. So, please write that as an answer and mark that answer as accepted. :-) – Kulfy Dec 9 '18 at 1:05
  • @Getsuga perhaps you created the user's .ssh directory with root user. If so, you also need to change the owner of the directory and its contents (presumably authorized_keys file) chown -R maydara:maydara /home/maydara/.ssh – aribo Aug 21 '19 at 13:51

To fix my problem I ended up removing my ssh folder and regenarating my keys:

rm -rf ~/.ssh
ssh-keygen -t rsa -b 4096
ssh-add ~/.ssh/[the_name_of_your_private_key]

then I uploaded my public keys again to github, digitalocean, etc.

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.