DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 966,155 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
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.

Top comments (1)

🌚 Friends don't let friends browse without dark mode.

Just kidding, it's a personal preference. But you can change your theme, font, etc. in your settings.

The more you know. 🌈