ssh - private key file requires \n at the end of file or cause "Load key id_rsa invalid format"

Question

Has OpenSSH introduced a change that requires \n at the end of the private key file (id_rsa)? Previously I was on Ubuntu 18.04 and I believe id_rsa without \n at the end of the file was working. Now on Ubuntu 20.04, ssh does not work if id_rsa does not have \n at the end of the file.

$ diff id_rsa.bak.od id_rsa.od
163,164c163,164
< 000a20 K E Y - - - - -
< 000a29
---
> 000a20 K E Y - - - - - \n
> 000a2a

Without the \n, it causes the error.

$ ssh -i ~/.ssh/id_rsa ubuntu
Load key "/home/hadoop/.ssh/id_rsa": invalid format

Environment

$ ssh -V
OpenSSH_8.2p1 Ubuntu-4ubuntu0.2, OpenSSL 1.1.1f 31 Mar 2020
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL=""
SUPPORT_URL=""
BUG_REPORT_URL=""
PRIVACY_POLICY_URL=""
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
2 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like