在Windows自动/脚本/命令行中将.pem密钥文件转换为.ppk [英] Convert .pem key file to .ppk in Windows automatically/script/command line

查看:352
本文介绍了在Windows自动/脚本/命令行中将.pem密钥文件转换为.ppk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Vagrant在Windows主机上创建虚拟机,我想将其与PuTTY连接. Vagrant以.pem格式创建RSA私钥. PuTTY需要.ppk格式的密钥才能创建连接.

I'm using Vagrant to create VMs on a Windows host, to which I would like to connect with PuTTY. Vagrant creates an RSA private key in the .pem format. PuTTY needs a key in the .ppk format to create a connection.

我想在创建无业游民的VM时自动将.pem转换为.ppk.

I would like to convert the .pem to .ppk automatically when creating the vagrant VM.

关于如何将.pem转换为.ppk的问题已经提出并回答了很多次,但是在Windows上,所有这些答案都涉及单击puttygen GUI.看来在Linux上,puttygen可以完全从命令行进行操作,但是在Windows上必须使用GUI.

The question of how to convert .pem to .ppk has been asked and answered lots of times, but on Windows all those answers involve clicking through the puttygen GUI. It seems that on Linux, puttygen can be operated entirely from the command line, but on Windows the GUI must be used.

在创建要避免的新VM时,必须单击GUI是我工作流程中的一个慢点.

Having to click through a GUI is a slow point in my workflow when creating new VMs that I would like to avoid.

在Windows上是否有任何命令行/可编写脚本/编程方式将.pem文件转换为.ppk格式?

Is there any command-line/scriptable/programmatic way of converting .pem files to .ppk format on Windows?

推荐答案

WinSCP 支持使用/keygen开关:

winscp.com /keygen mykey.pem /output=mykey.ppk

(我是WinSCP的作者)

或者,您可以使用Cygwin编译/运行Unix命令行puttygen.

Or, you can compile/run Unix command-line puttygen using Cygwin.

或者使用PuTTY代码构建自己的工具,它是开源的.这相当容易(这基本上就是WinSCP所做的).

Or build your own tool from PuTTY code, it's open-source. It is rather easy (that's basically what WinSCP does).

使用import_ssh2加载.pem:

ssh2_userkey *import_ssh2(const Filename *filename, int type,
                          char *passphrase, const char **errmsg_p);

使用ssh2_save_userkey将其另存为.ppk:

bool ssh2_save_userkey(
    const Filename *filename, ssh2_userkey *key, char *passphrase);

这篇关于在Windows自动/脚本/命令行中将.pem密钥文件转换为.ppk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆