Probably you pasted it wrong.
- Does it start with
ssh-rsa
or withssh-ed25519
? - Does it have a space before (it should NOT)
- Is upper/lower case preserved?
- is there a space before any comment at the end of the line?
before pasting anything in vim, you should use :set paste
, as it switches off any possible active autocompletion/autoindent/... macros.
Another thing is, that you wrote mykey.pem
, which is the usual extension for openssl files, not ssh-keys. Are you sure, you used the id_rsa.pub
/ id_ed25519.pub
as ssh-pubkey?