SSH:如何在脚本中用非空密码替换空密码
SSH: How to replace an empty passphrase with a non-empty passphrase in script
在脚本中,我需要将密码添加到密码为空的私钥。
我刚试过这个:
echo asdf | ssh-keygen -p -f ~/.ssh/id_rsa
ssh-keygen
有一个命令行选项来指定新密码(和旧密码,如果密钥已经有密码):
ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]
[...]
-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.
-P passphrase
Provides the (old) passphrase.
-N new_passphrase
Provides the new passphrase.
在脚本中,我需要将密码添加到密码为空的私钥。
我刚试过这个:
echo asdf | ssh-keygen -p -f ~/.ssh/id_rsa
ssh-keygen
有一个命令行选项来指定新密码(和旧密码,如果密钥已经有密码):
ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]
[...]
-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.-P passphrase
Provides the (old) passphrase.-N new_passphrase
Provides the new passphrase.