有没有办法将 PEM 文件转换为 PPK 文件?(您可能会猜到 Amazon EC2 给了我一个 PEM 文件,我需要使用 PPK 格式进行 SSH 连接)。
11 回答
Use PuTTYGen
Creating and Using SSH Keys
Overview
vCloud Express now has the ability to create SSH Keys for Linux servers. This function will allow the user to create multiple custom keys by selecting the "My Account/Key Management" option. Once the key has been created the user will be required to select the desired SSH Key during the “Create Server” process for Linux.
Create and Use SSH Keys
- Create keys
- Navigate to “My Account”</li>
- Select “Key Management”</li>
- Create New Key.
- During the key creation process you will be prompted to download your private key file in .PEM format. You will not be able to download the private key again as it is not stored in vCloud Express.
- The “Default” checkbox is used for the API.
- Deploy server and select key
Connect
- SSH (Mac/Linux)
- Copy .PEM file to the machine from which you are going to connect.
- Make sure permissions on .PEM file are appropriate (chmod 600 file.pem)
- Connect with ssh command: ssh vcloud@ipaddress –i privkey.pem
- Putty (Windows)
- Download Putty and puttygen from - here
- Use puttygen to convert .PEM file to .PPK file.
- Start puttygen and select “Load”</li>
- Select your .PEM file.
- Putty will convert the .PEM format to .PPK format.
- Select “Save Private Key” A passphrase is not required but can be used if additional security is required.
Connect with Putty.
- Launch Putty and enter the host IP address. If connecting to the 10.X private address you must first establish an SSL VPN connection.
- Navigate to Connection/SSH/Auth
Click “Browse” and select the .PPK file you exported from puttygen.
Click “Open.” When connection comes up enter username (default is vcloud).
- SSH (Mac/Linux)
Instructions copied from here
我很震惊,因为解决方案非常简单,所以这个问题没有得到回答。
如前几篇文章所述,您不想使用 C# 转换它,而只想转换一次。使用 PuTTYGen 很容易做到这一点。
- 从 AWS 下载您的 .pem
- 打开 PuTTYgen
- 单击右侧的“加载”大约向下 3/4
- 将文件类型设置为 *.*
- 浏览并打开您的 .pem 文件
- PuTTY 将自动检测所需的一切,您只需单击“保存私钥”即可保存您的 ppk 密钥以与 PuTTY 一起使用
享受!
- 下载puttygen
- 然后打开puttygen
- 点击加载
- 将文件类型设置为. 所有文件
- 保存私钥
- 然后你可以保存文件成为ppk文件的任何名称
如果您有 Linux 机器,只需在系统中安装 puttygen 并使用以下命令转换密钥
pem 到 ppk 使用以下命令:
puttygen keyname -o keyname.ppk
下面的命令用于将 ppk 转换为 pem 而不是 pem 到 ppk
puttygen filename.ppk -O private-openssh -o filename.pem
要通过 SSH 连接到 AWS EC2 实例,即使在 Windows 机器上,您也不需要将 .PEM 文件转换为 PPK 文件,使用“git bash”工具进行简单 SSH。无需下载和转换这些软件 - 希望这将节省您下载和转换密钥的时间,并让您有更多时间在 EC2 上。
- 将 YourPEMFILE.pem 保存到 .ssh 目录
从命令提示符运行 puttygen
一个。单击“加载”按钮以“加载现有的私钥文件”<br> b. 将文件过滤器更改为“所有文件 ( . )
选择 YourPEMFILE.pem
d。单击打开
e。Puttygen 显示一条通知说它已成功导入外键。单击确定。
F。点击“保存私钥”按钮
g。当询问您是否确定要在不输入密码的情况下保存时,回答“是”。
H。输入文件名 YourPEMFILE.ppk
i。点击“保存”</p>
用于 Ubuntu/Linux 和 PEM 到 PPK 的 PuTTYgen
sudo apt install putty-tools
puttygen -t rsa -b 2048 -C "user@host" -o keyfile.ppk
我使用了 ZOC 终端仿真器的试用版,它工作正常。它很容易接受亚马逊的 *.pem 文件。
诀窍是,您需要为用户名指定“ec2-user”而不是“root”——尽管 EC2 控制台中显示了示例,但这是错误的!;-)
sudo yum install putty
sudo apt-get install putty-tools
将 .pem 文件转换为 .ppk 文件
sudo puttygen pemKey.pem -o ppkKey.ppk -O private
将 .ppk 文件转换为 .pem 文件
sudo puttygen ppkkey.ppk -O private-openssh -o pemkey.pem
我对 PuttyGen 有同样的问题,不想导入 openSSH 私钥。我尝试了一切,我发现旧版本的 PuttyGen 不支持导入 OpenSSH。一旦我下载了最新的 Putty,puttygen 就允许它很好地导入 openssh 私钥。现在,我的办公桌边上有一个洞,过去一个小时我的头一直在撞它。