如何为没有密码生成的 OpenSSH 私钥添加密码? [英] How do I add a password to an OpenSSH private key that was generated without a password?

查看:36
本文介绍了如何为没有密码生成的 OpenSSH 私钥添加密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 puttygen 生成了一个 OpenSSH 私钥(并以 OpenSSH 格式导出).如何在现有密钥上设置密码(我知道如何使用密码生成新密钥)?

I generated an OpenSSH private key using puttygen (and exported it in OpenSSH format). How can I put a password on this existing key (I know how to generate a new key with a password)?

推荐答案

试试命令 ssh-keygen -p -f keyfile

来自 ssh-keygen 手册页

From the ssh-keygen man page

 -p      Requests changing the passphrase of a private key file instead of
         creating a new private key.  The program will prompt for the file
         containing the private key, for the old passphrase, and twice for
         the new passphrase.

 -f filename
         Specifies the filename of the key file.

示例:

ssh-keygen -p -f ~/.ssh/id_rsa

这篇关于如何为没有密码生成的 OpenSSH 私钥添加密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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