为 Posh-SSH New-SSHSession 提供私钥 passhprase(密码)

tec*_*007 6 ssh powershell sftp private-key posh-ssh

使用Posh-SSH,有没有办法提供密码短语/密码以与加密的私钥一起使用?(密钥文件的密码,而不是 SSH 服务器连接的凭据)

我没有运气找到关于如何做到这一点的信息,或者甚至可能。

有问题的 SFTP 服务器需要 SSH 密钥和登录密码。

Mar*_*ryl 6

Posh-SSH 将使用“密码”来解密加密的私钥。

$cred = New-Object System.Management.Automation.PSCredential($userName, $keyPassphrase)
$sftp = New-SFTPSession -ComputerName $hostname -Credential $cred -KeyFile $keyFile
Run Code Online (Sandbox Code Playgroud)

密钥密码和密码以相同的方式提供(糟糕的设计,imo)。我担心在 Posh-SSH 中使用双因素密钥+密码身份验证可能会很困难(如果可能的话)。