パスワードなしで生成された OpenSSH 秘密鍵にパスワードを追加するにはどうすればよいですか? 質問する

パスワードなしで生成された OpenSSH 秘密鍵にパスワードを追加するにはどうすればよいですか? 質問する

PuTTYgen を使用して OpenSSH 秘密鍵を生成し、OpenSSH 形式でエクスポートしました。

この既存のキーにパスワードを設定するにはどうすればよいですか (パスワードを使用して新しいキーを生成する方法は知っています)?

ベストアンサー1

次のコマンドを試してください:

ssh-keygen -p -f keyfile

ssh-keygenのマニュアルページより

 -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

おすすめ記事