我最近将主机从 Ubuntu 14.04 升级到 18.04,当我尝试ssh
在 18.04 下使用时,我收到错误消息key_load_public: invalid format
。
我在此主机(和远程)上使用的密钥对的公钥部分如下所示:
command="/root/bin/rsync_only" ssh-rsa AAAAB...kEzWH0cMQ== root@vargas
似乎如果我删除该command=
部分,我不会收到invalid format
错误消息。它多年来一直运行良好。有人知道为什么现在这是一个问题吗?
/root/bin/rsync_only
#!/bin/sh
case "$SSH_ORIGINAL_COMMAND" in
*\&*)
echo "Rejected"
;;
*\;*)
echo "Rejected"
;;
rsync\ --server*)
$SSH_ORIGINAL_COMMAND
;;
*)
echo "Rejected"
;;
esac
ssh -vvv
# ssh remote_host -i ~/.ssh/id_rsync -vvv
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017
debug1: Reading configuration data /root/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "remote_host" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to remote_host [10.10.16.1] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
key_load_public: invalid format
...
来自 Ubuntu 14.04 的 ssh 和 -vvv 输出
ubuntu-14.04 # ssh remote_host -i ~/.ssh/id_rsync
Rejected
Connection to remote_host closed.
ubuntu-14.04# ssh remote_host -i ~/.ssh/id_rsync -vvv
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /root/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to remote_host [10.10.16.1] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug3: Incorrect RSA1 identifier
debug3: Could not load "/root/.ssh/id_rsync" as a RSA1 public key
debug2: key_type_from_name: unknown key type 'command="/root/bin/rsync_only"'
debug3: key_read: missing keytype
...
command="/root/bin/rsync_only"
从公钥文件中删除文本。公钥文件应以 开头ssh-rsa
,并且应包含一长行文本。该
command="/root/bin/rsync_only"
指令是您可以添加到ssh服务器上的authorized_keys
文件以使服务器限制密钥以运行特定命令的内容。这不是您可以添加到公钥文件中的东西,而且对于像.ssh