使用SSH密钥的密码使Powershell应答提示

时间:2017-06-28 21:17:08

标签: git powershell ssh automation

我一直在试图弄清楚如何在PowerShell中回答提示。我的用例相当基本;在我启动PowerShell会话后,我希望加载SSH密钥。

我现在面临的问题是我手动必须为我的SSH密钥添加密码。我宁愿自动化。

这就是我现在要尝试的方法:

Add-SshKey 

Start-Sleep -Milliseconds 5000

[System.Windows.Forms.SendKeys]::SendWait(“MyPassword01{ENTER}”)

在提示过程中必须手动按Enter键后出现此错误:

MyPassword01 : The term 'MyPassword01' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ MyPassword01
+ ~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (MyPassword01:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

另一个奇怪的行为是,字符串MyPassword01似乎已写入错误上方的PowerShell窗口,但是AFTER 提示符:

Enter passphrase for /c/Users/Todai/.ssh/ps_id_rsa:
Finished!
Loading personal and system profiles took 25940ms.
~ $ MyPassword01

0 个答案:

没有答案