在powershell中自动执行github的ssh-keygen [英] automate ssh-keygen for github in powershell
问题描述
有没有办法在powershell中自动化 ssh-keygen
方法?我试图用下面的代码来完成它,但它需要用户输入密码。
Is there a way to automate the ssh-keygen
method in powershell? I'm trying to do it with the following code, but it requires the user to enter a password.
# Create your GitHub SSH Key
$MyEmailAddress = "some.user@github.com"
if (! (Test-Path ("~/.ssh/id_rsa_test"))){
ssh-keygen -t rsa -C "$MyEmailAddress" -f "id_rsa_test"
}
我尝试输入密码开关,但后来它抱怨密码为空。
I tried entering the password switch, but then it complains that the password is null.
# either
ssh-keygen -t rsa -C "$MyEmailAddress" -f "id_rsa_test" -N ""
# or
ssh-keygen -t rsa -C "$MyEmailAddress" -f "id_rsa_test" -N "$null"
我不想在密钥中输入密码。
I don't want a password in my key.
PS:我正在使用 poshgit 取决于 mysysgit 。
PS: I'm using poshgit which depends on mysysgit.
推荐答案
PowerShell似乎删除了空的双层电子报,并可能需要逃避它们。使用而不是
似乎有效。另外,我相信你应该使用
-P
(密码短语),而不是 -N
)。所以最后的命令行应该是 ssh-keygen -t rsa -C$ MyEmailAddress-fid_rsa_test-P
。
PowerShell seems to remove the empty double quotes and probably requires to escape them. Using """"
instead of ""
seems to work. Also, I believe one should use -P
(passphrase) instead of -N
(new passphrase in case you change it). So the final command line would be ssh-keygen -t rsa -C "$MyEmailAddress" -f "id_rsa_test" -P """"
.
这篇关于在powershell中自动执行github的ssh-keygen的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!