Topic "SFTP SSH Hostkey match works but fails under SQL Agent Job"

Author Message
Greg Munson
[View user's profile]

Joined: 2016-07-27
Posts: 2
Running WinSCP 5.7.7 on windows 2012 server, SQL 2014 standard and SSDT v12 under MS Visio Studio 2013;
Have an SSIS package using Execute Process task to launch Batch file which launches WinSCP to connect SFTP to server using ID:pwd and hostkey fingerprint validation. When running SSIS package from SSDT and/or SSMS under my ID- all good - see last seesion snipit in attached logfile; however when running same package (eg same batch file and winscp script) under SQL Server Agent Job schedule - it gives error that host key does not match - yet even in log printout the keys are the same (see first snipit in attached file). I'm guessing it's some hidden code page or undisplayable character translation bug? Any help or suggestions?
this is snip of winscp script file
Logfile content:
"%PROGRAMFILES(x86)%\WinSCP\WinSCP.com" /log=D:\Card_UCCE_CDW_Extract\Logfiles\winscplog.txt /loglevel=1 /script=D:\Card_UCCE_CDW_Extract\Program_Files\Hadoop_Connection.txt /parameter // %*

Winscp scipt file:
open %1% "-hostkey=""%4%"""
cd %3%
ls
put %2%
ls
exit
close
errorexamplelog.txt (13.89 KB) Private file

Description: Log file of error when using SQL Agent (COF\sql_agent_user) and success under my ID (COF\a-dcs032)
(scrubbed password but not client domain names - please do no post file as-is)

Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
You have too many quotes there.

It should be:

open %1% -hostkey="%4%"

This works too (but the above is preferred):

open %1% "-hostkey=%4%"
Greg Munson
[View user's profile]

Joined: 2016-07-27
Posts: 2
Thank-you....had been playing with quotes but it was originally giving a 'too many parameters' error - then the confusion was it finally "worked", even with those extra quotes, under my ID - falsity was that (apparently) it was using a key cached in the registry and not the key I was passing to it (unfortunately it never indicated that!?)...set /ini=nul and it started failing on my ID as well ....then was able to fix both with your correction to quotes.
Is there any way to see the indication that it checked the cached key 'under the covers' in case others encounter similar feature?
Thanks
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
In scripting, you should always use the /ini=nul exactly for this reason.
https://winscp.net/eng/docs/scripting#configuration

In the session log file you can see if the host key was verified against the "cached" or the "configured" key.
Advertisements

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!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License