How to make winscp automatically accept server host key?

Advertisement

JmenoBezCeskychZnakuBoze
Joined:
Posts:
5

How to make winscp automatically accept server host key?

I'm writing a script to transfer data via winscp using its powershell functionality.

I need to use SFTP and automatically accept host key fingerprint on first connection and on all further ones, no matter what is the value.
How do I script that, pls?

When I write a script without specifying hostkey, it throws this back at me:

Exception calling "Open" with "1" argument(s): "SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOptions.HostKey is not set."

Reply with quote

Advertisement

JmenoBezCeskychZnakuBoze
Joined:
Posts:
5

I might have phrased it a bit better...

Well, simply. I don't have a fingerprint of that server key and I don't care about changes of the server key. I don't want to use the fingerprint and want to accept the server key automatically without any prompt. How can I suppress the prompt and accept it automatically without having fingerprint?

Reply with quote

Guest

Re: How to make winscp automatically accept server host key?

martin wrote:

Use SessionOptions.GiveUpSecurityAndAcceptAnySshHostKey.
Please read documentation, boze:
https://winscp.net/eng/docs/library_sessionoptions


The link shows syntax for C# and VB.net. I'm running WinSCP from a batch file using command line parameters. Can you set session options in a batch file? An example would be appreciated

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
Location:
Prague, Czechia

Re: How to make winscp automatically accept server host key?

The link shows syntax for C# and VB.net. I'm running WinSCP from a batch file using command line parameters. Can you set session options in a batch file? An example would be appreciated
In scripting, you can (but should not!) use -hostkey=*
See https://winscp.net/eng/docs/faq_hostkey#automation and https://winscp.net/eng/docs/scriptcommand_open#hostkey

Reply with quote

Advertisement

You can post new topics in this forum