Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Provide private key passhprase (password) for Posh-SSH New-SSHSession

With Posh-SSH, is there a way to provide the passphrase/password to use with an encrypted private key? (Password for the key file, not credentials for the SSH server connection)

I'm having no luck finding information on how to do it, or if it's even possible.

The SFTP server in question requires both the SSH keys, as well as a login password.

like image 296
techie007 Avatar asked Oct 19 '18 17:10

techie007


1 Answers

Posh-SSH will use "password" to decrypt encrypted private key.

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

Key passphrase and password are provided the same way (bad design, imo). I'm afraid that using two-factor key+password authentication in Posh-SSH might be difficult, if possible at all.

like image 193
Martin Prikryl Avatar answered Nov 11 '22 10:11

Martin Prikryl