Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab key format issue

I am facing a strange situation where I am using gitlab account to handle my code. I am using ssh protocol to access the repo. I am able to pull the code but I am receiving the following error while I try to push the code. This could be something silly on my side. But I have the keys stored in my gitlab profile and able to use it to pull the code.

Error :

$ git push origin master
key_load_public: invalid format
Enter passphrase for key '/c/Users/username/.ssh/id_rsa':
Access denied.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
like image 570
jqheart Avatar asked Oct 23 '15 12:10

jqheart


People also ask

What is OpenSSH private key format?

So, the OpenSSH private key format ultimately contains a private key encrypted with a non-standard version of PBKDF2 that uses bcrypt as its core hash function. The structure that contains the key is not ASN. 1, even though it's base64 encoded and wrapped between header and footer that are similar to the PEM ones.

Can I use the same SSH key for GitHub and GitLab?

Use the same ssh key across applications No need to make complicated ~/. ssh/config files; just give each GitHub/GitLab account the same public key and you're done.

How do I add a key to GitLab?

Log into GitLab and click on your account preferences. Click the SSH Keys link and paste the copied value into the text field. Set an expiration date, and then click the blue button to persistently add the GitLab SSH key. Configure GitLab SSH keys under your account preferences.

What is SSH key in GitLab?

The SSH stands for Secure Shell or Secure Socket Shell used for managing the networks, operating systems and configurations and also authenticates to the GitLab server without using username and password each time. You can set the SSH keys to provide a reliable connection between the computer and GitLab.


2 Answers

Finally I have been able to resolve this issue and I am posting it for other users. If the keys generated by putty is not helping you to access the gitlab repo, try generating the keys from gitbash terminal using the command ssh-keygen and save the files in .ssh folder of your user account.

The linux style key generation made my life easy as I was trying to generate key in windows environment with putty keygen.

Hope this helps somebody.

like image 191
jqheart Avatar answered Sep 20 '22 05:09

jqheart


PuTTYGen can generate the correct OpenSSH keys.

  1. Generate your key file, save the private key (with or without a passphrase)
  2. Add your username/email address as the comment
  3. Copy the contents of the generated key and paste it into your id_rsa.pub
  4. Export the OpenSSH private key using the menu and save it as id_rsa

Export OpenSSH Key

like image 20
Glen Blanchard Avatar answered Sep 18 '22 05:09

Glen Blanchard