【问题标题】:SSH: How to replace an empty passphrase with a non-empty passphrase in scriptSSH:如何在脚本中用非空密码替换空密码
【发布时间】:2018-04-20 02:03:19
【问题描述】:

在脚本中,我需要将密码添加到具有空密码的私人密钥。

我刚刚试过这个:

echo asdf | ssh-keygen -p -f ~/.ssh/id_rsa

【问题讨论】:

标签: linux ssh openssh


【解决方案1】:

ssh-keygen 有一个命令行选项来指定新密码(如果密钥已经有密码,旧密码):

ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]
[...]
-p
请求更改私钥文件的密码,而不是创建新的私钥。程序将提示输入包含私钥的文件、旧密码短语和两次新密码短语。

-P 密码
提供(旧)密码。

-N new_passphrase
提供新密码。

【讨论】:

    猜你喜欢
    • 2023-03-14
    • 2013-02-12
    • 2015-03-15
    • 2021-08-13
    • 1970-01-01
    • 2015-11-03
    • 2012-05-01
    • 2016-12-06
    • 2019-01-17
    相关资源
    最近更新 更多