ssh - 私钥文件需要 \n 在文件末尾或导致“加载密钥 id_rsa 格式无效”

时间:2021-06-08 09:32:32

标签: openssh

问题

OpenSSH 是否引入了需要在私钥文件 (id_rsa) 末尾添加 \n 的更改?以前我使用的是 Ubuntu 18.04,我相信文件末尾没有 id_rsa\n 可以正常工作。现在在 Ubuntu 20.04 上,如果 id_rsa 在文件末尾没有 \n,ssh 将不起作用。

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

如果没有 \n,则会导致错误。

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

环境

$ 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="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

0 个答案:

没有答案
相关问题