PS, Winscp: "New-WinSCPSession : Exception calling "Open" with "1" argument(s): "SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOptions.SshHostKeyFingerprint is not set."

Hi,

I'd like to use winscp but do not have a fingerprint. Yes, I know that's a security risk but not where I use it.

This is the tool https://gallery.technet.microsoft.com/WinSCP-PowerShell-Module-ee1601ff



How can I find a way around it?
J.
janhoedtAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dan McFaddenSystems EngineerCommented:
What protocol are you using, SFTP or SCP?  If SFTP, you can switch to just the FTP protocol and then no finger print is required.

Can you post the script throwing the error?

Dan
1
janhoedtAuthor Commented:
Not sure, the default one, guess that's scp.
There is no error, it just asks for a fingerprint which I do not have.
0
Dan McFaddenSystems EngineerCommented:
You control the protocol by setting the Session Options in the script.  There are 2 ways of doing this:

1.
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::Ftp
        HostName = $ftpServer
        PortNumber = 21
        UserName = $userName
        Password = $passWord
}

Open in new window


Here you directly declare the protocol in the Session Options property array.

2.
$sessionUrl = "ftp://"+$userName+":"+$passWord+"@"+$ftpServer+"/"
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.ParseUrl($sessionUrl)

Open in new window


Here, you declare the protocol (also ftp) by building a string that is then consumed by the Session Options using the ParseUrl method.

Reference link:  https://winscp.net/eng/docs/library_sessionoptions

Dan
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Defend Against the Q2 Top Security Threats

Were you aware that overall malware worldwide was down a surprising 42% from Q1'18? Every quarter, the WatchGuard Threat Lab releases an Internet Security Report that analyzes the top threat trends impacting companies worldwide. Learn more by viewing our on-demand webinar today!

janhoedtAuthor Commented:
is wnscp ftp? (!)
0
Dan McFaddenSystems EngineerCommented:
To quote the WinSCP website:


WinSCP is a popular SFTP client and FTP client for Microsoft Windows!
Copy file between a local computer and remote servers using
FTP, FTPS, SCP, SFTP, WebDAV or S3 file transfer protocols.

So yes, WinSCP can be used with several file transfer protocols, FTP being one of them.

Dan
0
janhoedtAuthor Commented:
Apparently we use sftp, what is not working with the commands here.

$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::sFtp
        HostName = $ftpServer
        PortNumber = 22
        UserName = $userName
        Password = $passWord
}

Error is:
SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOptions.SshHostKeyFingerprint is not set. (raised by: New-WinSCPSession)

New-WinSCPSession -SessionOption $sessionOptions
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.