After a fresh install of Ubuntu 15.10, when using scp
or git clone
, I get the following warning (the command itself doesn't fail): key_load_public: invalid format
How can I get rid of this warning?
Update:
This is the output of scp -vvv
:
OpenSSH_6.9p1 Ubuntu-2, OpenSSL 1.0.2d 9 Jul 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to ... [...] port 22.
debug1: Connection established.
key_load_public: invalid format
debug1: identity file /home/alexzeitler/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/alexzeitler/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/alexzeitler/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/alexzeitler/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/alexzeitler/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/alexzeitler/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/alexzeitler/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/alexzeitler/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9p1 Ubuntu-2
Check the file
/Users/alexzeitler/.ssh/id_rsa
. What is there? How did it get there?It should be your private RSA key, isn't it? And is there something in
/Users/alexzeitler/.ssh/id_rsa.pub
? Is it valid public key?If you don't use these keys, remove both of them and the message will disappear. If you are using them in different way, move them somewhere else. The same if they are in different format.
The public part is probably corrupted, so you can recreate it from private one using this command:
###hostkeys possibility The other possibility is that client is trying to read server public keys for
HostBasedAuthentication
. Don't you have it allowed in/etc/ssh/ssh_config
?It would be one of these files missing or corrupted:
Your
sshd
server is not complaining?I had a similar error
Load key "/root/.ssh/id_rsa": invalid format
when I tried in a Dockerfile:This led to errors like
identity file /root/.ssh/id_rsa type -1 invalid format
andread_passphrase: can't open /dev/tty
. Do not useecho "${SSH_PRIVATE_KEY}" >> /root/.ssh/id_rsa
to pass the private key!The right way would be to use
The solution explained: my private key was wrongly formatted - instead of many lines, it was passed as a one-liner, and you might have any other format issue like a forgotten "-" at the start or end, or something wrong at the end of the lines, like a missing newline format or an additional letter at the end of a line.
See Dockerfile: clone repo with passwordless private key. Errors: “authentication agent” or “read_passphrase: can't open /dev/tty” for more details, with the main idea from Add private key to ssh-agent in docker file, which again had the idea from Gitlab CI/Docker: ssh-add keeps asking for passphrase.