amazon-ec2 - AWS EC2 不会导入 OpenSSH ECDSA 密钥
问题描述
我想将 ECDSA 密钥导入 AWS EC2。AWS EC2 是否只导入 RSA 密钥,而不是 ECDSA 或 ED25519 密钥?如果有办法导入 ECDSA 密钥,该怎么做?
# Discover the apt package that provided ssh-keygen
$ apt-file search `which ssh-keygen`
openssh-client: /usr/bin/ssh-keygen
openssh-client-ssh1: /usr/bin/ssh-keygen1
# Discover the installed version of openssh-client
$ apt list openssh-client
Listing... Done
openssh-client/groovy,now 1:8.3p1-1 amd64 [installed,automatic]
# Make a new key pair
$ ssh-keygen -b 521 -f ~/.ssh/key2020-10-28 -P "" -t ecdsa
# Import the new key pair
$ aws ec2 import-key-pair --key-name key2020-10-28 \
--public-key-material fileb://~/.ssh/key2020-10-28.pub
#An error occurred (InvalidKey.Format) when calling the ImportKeyPair operation:
#Key is not in valid OpenSSH public key format
# Try again with a base64 encoded key:
$ base64 ~/.ssh/key2020-10-28.pub > ~/.ssh/key2020-10-28.pub.b64
$ aws ec2 import-key-pair --key-name key2020-10-28 \
--public-key-material fileb://~/.ssh/key2020-10-28.pub.b64
# An error occurred (InvalidKey.Format) when calling the ImportKeyPair operation:
# Key is not in valid OpenSSH public key format
接下来我尝试了旧的 RSA 密钥算法,该算法有效:
ssh-keygen -b 4096 -f ~/.ssh/ec2 -P "" -N "" -t rsa
aws ec2 import-key-pair --key-name rsa2020-10-28 \
--public-key-material fileb://~/.ssh/rsa2020-10-28.pub
{
"KeyFingerprint": "c9:32:25:36:fd:b8:a0:83:09:1b:56:6f:86:a1:18:4e",
"KeyName": "rsa2020-10-28",
"KeyPairId": "key-04ebd4202d5988526"
}
接下来我尝试了旧的和不安全的 DSA 密钥算法:
ssh-keygen -f ~/.ssh/dsa2020-10-28 -P "" -t dsa
aws ec2 import-key-pair --key-name dsa2020-10-28 \
--public-key-material fileb://~/.ssh/dsa2020-10-28.pub
An error occurred (InvalidKey.Format) when calling the ImportKeyPair operation:
Key is not in valid OpenSSH public key format
接下来我尝试了ed25519密钥算法:
ssh-keygen -f ~/.ssh/ed25519-2020-10-28 -P "" -t ed25519
aws ec2 import-key-pair --key-name dsa2020-10-28 \
--public-key-material fileb://~/.ssh/ed25519-2020-10-28.pub
An error occurred (InvalidKey.Format) when calling the ImportKeyPair operation:
Key is not in valid OpenSSH public key format
解决方案
您现在可以根据此公告将 ED25519 密钥用于 EC2 实例。
推荐阅读
- c# - System.AccessViolationException 特别是在 Windows 10 上通过 .NET 4.0 的 clr.dll 库中的指针进行迭代时
- java - 控制台中的时间刷新
- reactjs - 如何使用从 Redux 状态到 Marker 坐标的经纬度
- sql - 将 VARCHAR 24 小时时间转换为 12 小时
- hyperledger-fabric - 在 hlf1.4 中安装和启动旧网络 (.BNA) 文件
- javascript - 如何使用 axios.get 渲染数据
- google-apps-script - 在所有谷歌电子表格中使用谷歌脚本需要帮助
- python - 查找特定文本,在该文本上方的行中在设置的位置插入字符
- javascript - `return` 会在 try/catch 块中被错误捕获吗?
- python - 如何从一列的每一行中提取强标签之间的粗体字母单词?