ssh won't load key (error in libcrypto or Permission denied (publickey)) but ssh-add can load key

Problem:

Key can be added by ssh-agent and ssh worked fine

eval $(ssh-agent -s)
ssh-add ~/.ssh/id_ed25519
ssh -T [email protected]

but without ssh-agent, ssh won't load the key, even if key path is specified in .ssh/config

ssh -T [email protected]
[email protected]: Permission denied (publickey).

ssh -Tv [email protected]
debug1: Trying private key: /root/.ssh/id_ed25519
Load key "/root/.ssh/id_ed25519": error in libcrypto

Solution:

Check key file is in Unix EOL format and key file is ended with a newline.

The last line should be a blank line, not -----END OPENSSH PRIVATE KEY-----

Last updated