DEV Community

Cover image for Managing SSH keys!!
shamnad-sherief
shamnad-sherief

Posted on

Managing SSH keys!!

It was all sudden. I configured my ssh key and it shows you are not authorised to make any changes!!??

So what it is? Why this happens??

While trying to figure it out I understood that the ssh agent is confused with the identity file. You can see the permission is denied from the public key. The problem is caused after I added my Gitlab ssh key. Assuming the ssh-agent is confused with my Gitlab and Github ssh keys. When I try to push something, ssh checks for my identity file and it doesn’t know which file to pick!! So it might picked Github ssh key for Gitlab server which caused the error.

Solution

The problem was identifying the identity file. So I made a config file in .ssh folder for a better understanding.

vi ~/.ssh/config

Host gitlab.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/gitlab_key_location
Host github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/github_key_location
Enter fullscreen mode Exit fullscreen mode

Now the ssh agent knows where to look for the private key for each hosts.

Latest comments (0)