我制作了一个bash脚本来自动创建.pem文件 我认为它可以帮助某些人。
#! /bin/bash
#Based on https://linuxaws.wordpress.com/2017/07/17/how-to-generate-pem-file-to-ssh-the-server-without-password-in-linux/
user=$(echo "$USER")
ssh-keygen << EOF
$user
EOF
mv $user $user.pem
sudo chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys
sudo chmod 600 ~/.ssh/authorized_keys
cat $user.pub >> ~/.ssh/authorized_keys
echo "Copy the $user.pem to your computer."