I had this probelm when trying to copy/paste keys created on Windows 10.
Sometimes exported keys get unwanted or unintended formatting. Its best just to cat out the key and copy paste it directly from the Terminal. That way (unless you have some custome setup for your terminal output) you can be sure that you are copying just the key in plain text, without any extra formatting or anything.
If you can’t cat the key and copy directly from Terminal, then I would suggest copy pasting your key into a text editor that is specifically designed for handling code. This will make sure that they key is pasted in plain text and it will allow you remove any unwanted formatting.
If you don’t have a native program, you can use pastebin - you will just have to remember not to actually save your key, or at the very least delete it aftewards.
Its always probably a good idea to note that although my problem was created by Windows 10 - any system, even a Linux based one, can add weird formatting or characters to your key if you try opening it with native programs instead of directly copying from Terminal.