id_rsa.pub file SSH Error: invalid format

The IdentityFile configuration parameter should be pointed at the private key which the SSH client uses to prove its identity to the remote server. (The remote server, then, should have the contents of id_rsa.pub installed in its authorized_keys file, or an equivalent location).

You should be putting the path to id_rsa, not id_rsa.pub, as an argument to IdentityFile in your ~/.ssh/config.


The following permissions should be set:

Private keys should get rw for owner, none for group, none for others:

chmod 600 id_rsa

Public keys should get rw for owner, r for group, r for others:

chmod 644 id_rsa.pub