Git clone. key_load_public: invalid format Permission denied (publickey)

git@github.com: permission denied (publickey).
key_load_public: invalid format ssh
key_load_public invalid format permission denied (publickey gssapi keyex gssapi with mic)
load key invalid format permission denied (publickey)
key is invalid. you must supply a key in openssh public key format
git bitbucket org permission denied (publickey)
jenkins permission denied (publickey)
git bash key invalid format

I used puttygen.exe on Windows 10 to generate private and public keys. I saved that keys in C:\Users\Alexander\.ssh\

Public key was added to remote repo (Not by me. I don't have an access).

Then I used command in Git Bash:

git clone git@ipaddress:project_name.git

And I got an error:

key_load_public: invalid format
Permission denied (publickey).
fatal: Could not read from remote repository.

Example keys (generated for just for example)

id_rsa.ppk

PuTTY-User-Key-File-2: ssh-rsa
Encryption: none
Comment: rsa-key-20170110
Public-Lines: 6
AAAAB3NzaC1yc2EAAAABJQAAAQEAx0UhtZcgUT5XpoNlcoVFGHbArEsARQVCv5m0
TRh90Xq15gxOvL+x7I0B29xOuOP054RtQaOzHqnKUzpMdrIoZFkYEYJ11p42kC05
PVR/CwtKBuONJZzoIveJlNG1IhbC3G8DMZD5j68T5OVbCqftHMIBe4CTr7TewJ9T
/lmSZPytWXk/Xtcvn1i1TQZS2ShtSNOwtx77fLzkVmC6F4uM2JgJ9bSM2xQZTX/j
DYZTtoEsmyBadANAEZx4kQAoITwxXVRPBPJnB74EdSMXNhrDBJ+sZSEy7kxmc3a/
UK6CzdN3wiEMd/Bb1nuzR2cpWrWhniG66lnOTJb3sF8iiVtw7Q==
Private-Lines: 14
AAABAEtmRBsyQ5RcxzgWCrW14sr8gEExIrJVBH/ZSyQXGtmkDXmjysP1gZfGpsHk
qCpIaoEdWcXPPNsrfPzloGRDaTq57W5otvdCyImUkjLhs4ejaB5IQz6qEqVya2i+
DS9+O+S0YhLBO9WAhBFrijtiIl3oivB11wQ2mXlRCwZLZ9MugQ3rPfS0O/E2asrO
+MyiR2uv84lVb2wUT0Be3eeubnT2Qp8CoX3qV93LwBM053tepmD0jtSBsaXepADw
mdjBfIkUm+z/69PKtsEoY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iVtw7Q==
---- END SSH2 PUBLIC KEY ----

What may be wrong here?

key_load_public: invalid format, The putty format public key doesn't work. In any case, my error is as follows: $ ssh -T git@github.com key_load_public: invalid format Enter� Re: "invalid format Permission denied (publickey)" If you are on GitHub hosted runners your IP address needs to be accessible to the internet. If it is a private IP it would not be reachable from the runner machine.

Sorry for answering an old question, but the listed solutions didn't help. Here's what worked for me:

Git may not be using the correct SSH client for outgoing connections.

I was having a similar issue and ended up finding an answer that set me on the right track to fix it. From what I understand, both Git & My command line where generating key-pairs using openssh, but Git was attempting to open them using it's own SSH client.

I'm not sure why Git would use two different ssh clients, one for generating, one for connecting, but this was evidenced by being able to verify my key by opening an SSH session to GitHub, but not connect to a repository. A further check seemed to validate the theory:

C:\where ssh
C:\Windows\System32\OpenSSH\ssh.exe

And in git bash:

$ where ssh
C:\Program Files\Git\usr\bin\ssh.exe

While trying the commands listed in the answer didn't fix my problem, they led me on a much more successful google search that got me to this GitHub comment, which contained the following single line command, to be run in git bash:

git config --global core.sshCommand "'C:\Windows\System32\OpenSSH\ssh.exe'"

This command will not output anything if it works, but it will set git to use the ssh client packaged with windows instead of the one included with git. After running this command, Git worked flawlessly for me.

Weirdly enough, running "where ssh" in git bash now returns two paths, but it doesn't seem to be causing any more issues:

$ where ssh
C:\Program Files\Git\usr\bin\ssh.exe
C:\Windows\System32\OpenSSH\ssh.exe

Fix "Permission denied (publickey)" error when pushing with Git , So when you run git clone git@github.com:ChannelJuanNews/myrepo.git it will look So that ssh -T git@github.com will return Permission Denied (publickey) , but sudo (git config --lis) remote.origin.url is correct (not .git, this should be a url format) EDIT: I was wrong about the keys not being visble in the Windows FS. Public key was added to remote repo (Not by me. I don't have an access). Then I used command in Git Bash: git clone git@ipaddress:project_name.git And I got an error: key_load_public: invalid format Permission denied (publickey). fatal: Could not read from remote repository. Example keys (generated for just for example) id_rsa.ppk

Verify the next things:

  1. Check if you have an empty id_rsa.pub file in the ~/.ssh directory. There could be more than one .pub files in there (depend on what you have already created). If you find a blank .pub file, go to where it should be kept in a remote server, in the ~/.ssh/authorized_keys file (on the server). Copy it's values and paste in your local public key file. Save.

  2. If everything correct in your local public keys, check that you didn't pasted the private key to your server or something.

ssh key_load_public: invalid format warning, There are two separate messages: This one tells you that .ssh/private_rsa_key is in wrong format: key_load_public: invalid format debug1: identity file� So that ssh -T git@github.com will return Permission Denied (publickey), but sudo ssh -T git@github.com works fine. If you want to generate ssh key for the user: admin , you can change current user to admin then generate ssh key.

key_load_public: invalid format with scp or git clone on Ubuntu , Check the file /Users/alexzeitler/.ssh/id_rsa . What is there? How did it got there? It should be your private RSA key, isn't it? And is there� When attempting to clone, push or pull over SSH with Git or Mercurial, you receive the message Permission denied (publickey). abort: no suitable response from

SSH Suddenly returning Invalid format, Check the contents of key_name , if the agent says invalid format , then there's You might have placed your public key in there, for some reason. diff ~/.ssh/ gitlab ~/.ssh/git_ssh_key 27c27 < -----END OPENSSH PRIVATE KEY----- keys I think, and then left me with that error, which was legit, just for the wrong identity file. key_load_public: invalid format it happened because somehow my local ~/.ssh/xxx.pub actually had contents of my private key file even though the remote host correctly had my public key in file ~myid/.ssh/authorized_keys SO solution was to correct my local ~/.ssh/xxx.pub so it had my public key

Git via SSH from Windows, Permission Denied, git clone git@github.com:parithon/CoreWiki.git Cloning inti 'CorWiki' git@github. com: Permission denied (publickey). fatal: Could not read from remote repository. Please ssh/id_rsa type -1 debug1: key_load_public: No such file or directory debug1: identity file C:\\Users\\. Am I doing something wrong? ssh-keygen -y -f Private-Key.pem > Public-key.pub. make sure the PUBLIC key has a .pub file extension. after that provide proper permissions for security reasons: chmod 600 Private-Key.pem chmod 400 Public-key.pub. THEN the most important part and the reason you got the error "invalid format".

Comments
  • Well, you will probably have to move the id_rsa.pub away, because the client can't read it.
  • It didn't help. I think the generated public key is not valid for OpenSSH. It should start with ssh-rsa AAAAB3NzaC1yc.... But my key starts with some comments and there is no ssh-rsa words.
  • Yes. Move the public key above away or replace it wit openssh format.