Topic "using Private key in Powershell"

Author Message
ruban chandar
[View user's profile]

Joined: 2014-06-19
Posts: 2
Location: India
I am using .Net assembly with powershell commands, i am moving the files from server to local folder, everything is working fine, however i have some issue with the authentication, i want to use my Private key instead of using public key fingerprint, this worked fine in command scripting, but in powershell i get the error message. "SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOptions.HostKey is not set." The code works when i mention the public key finger print, Below is the sample code, can anyone post any example to just use Private key location.

$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$sessionOptions.HostName = ""
$sessionOptions.UserName = "userName"

$sessionOptions.SshHostKeyFingerprint = "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"

$session = New-Object WinSCP.Session
$session.ExecutablePath = "C:\Program Files (x86)\WinSCP\winscp.exe"
#all the file transfer operations
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24736
Location: Prague, Czechia
You always have to specify host key fingerprint. This has nothing to do with private key (i.e. is not an alternative to).
Martin Prikryl

You can post new topics in this forum

Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License