Topic "Host key wasn't verified!"

Author Message
sql101
[View user's profile]

Joined: 2012-05-16
Posts: 1
Location: USA
Hi,
I am using the script tool to ftp to our secure ftp site. Could you please help me to see whcih part went wrong? It is conplaining about the hostkey when running through SQL Analyer but no problem if I typed them manually in command prompt

I have a batch file sftp_test.bat with one line command
WinSCP.com /script=D:\sftp_test.txt

sftp_test.txt contains the following
=======================================
option batch off
option confirm off
open username:pasword@site
Put d:\TestYYYYMMDD.txt
close
exit
=======================================
I have no problem running it by double clicking it or through the NY schedular but I can not run through SQL (I want to schudule as a SQL Job then with all the notification benefits)

When I run through SQL analyzier "exec master.dbo.xp_cmdshell 'D:\sftp_test.bat'"

here is the result I got

NULL
C:\Windows\system32>WinSCP.com /script=D:\Uploads\sftp_CAPSJob.txt
batch off
confirm off
Searching for host...
Connecting to host...
Authenticating...
The server's host key was not found in the cache. You have no guarantee that the server is the computer you think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 6d:c9:34:0e:8a:bb:3e:26:3a:75:9d:38:1a:13:11:0e
If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel.
Continue connecting and add host key to the cache?
(Y)es, (N)o, C(a)ncel, (C)opy Key: Cancel
Host key wasn't verified!
Authentication failed.
NULL


But I want to be able to use SQL agent instead of the cmd prompt or schedular

much thanks
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
Please read FAQ:
http://winscp.net/eng/docs/faq_scheduler
_________________
Martin Prikryl
tsantony
[View user's profile]
Donor
Joined: 2013-01-04
Posts: 12
hi,

this is antony here, did you get the answer for your question? i'm also facing the same issue.
please help me.

regards,
Antony

sql101 wrote:
Hi,
I am using the script tool to ftp to our secure ftp site. Could you please help me to see whcih part went wrong? It is conplaining about the hostkey when running through SQL Analyer but no problem if I typed them manually in command prompt

I have a batch file sftp_test.bat with one line command
WinSCP.com /script=D:\sftp_test.txt

sftp_test.txt contains the following
=======================================
option batch off
option confirm off
open username:pasword@site
Put d:\TestYYYYMMDD.txt
close
exit
=======================================
I have no problem running it by double clicking it or through the NY schedular but I can not run through SQL (I want to schudule as a SQL Job then with all the notification benefits)

When I run through SQL analyzier "exec master.dbo.xp_cmdshell 'D:\sftp_test.bat'"

here is the result I got

NULL
C:\Windows\system32>WinSCP.com /script=D:\Uploads\sftp_CAPSJob.txt
batch off
confirm off
Searching for host...
Connecting to host...
Authenticating...
The server's host key was not found in the cache. You have no guarantee that the server is the computer you think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 6d:c9:34:0e:8a:bb:3e:26:3a:75:9d:38:1a:13:11:0e
If you trust this host, press Yes. To connect without adding host key to the cache, press No. To abandon the connection press Cancel.
Continue connecting and add host key to the cache?
(Y)es, (N)o, C(a)ncel, (C)opy Key: Cancel
Host key wasn't verified!
Authentication failed.
NULL


But I want to be able to use SQL agent instead of the cmd prompt or schedular

much thanks
drfunk2458
[View user's profile]

Joined: 2012-10-15
Posts: 7
Location: East Coast
did you try using the "/privatekey=" option ??
tsantony
[View user's profile]
Donor
Joined: 2013-01-04
Posts: 12
Hi,

yes i'm using Privatekey option

currently i'm receiving different Error

Information: 21/Jan/2013 10:16:04 Searching for host...
Information: 21/Jan/2013 10:16:04 Connecting to host...
Information: 21/Jan/2013 10:16:04 Authenticating...
Information: 21/Jan/2013 10:16:04 The server's host key was not found in the cache. You have no guarantee that the server is the computer you think it is.
Information: 21/Jan/2013 10:16:04 The server's rsa2 key fingerprint is:
Information: 21/Jan/2013 10:16:04 ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.....
Information: 21/Jan/2013 10:16:04 Connection : open sftp://sftpmazda@xxx.xxx.xxx.xxx:xxxxx -hostKey="ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx....."
Error: 21/Jan/2013 10:16:06 Connection has been unexpectedly closed. Server sent command exit status 0.
Error: 21/Jan/2013 10:16:06 Authentication log (see session log for details):
Using username "sftpmazda".
Access denied.

Error: 21/Jan/2013 10:16:06 Authentication failed.

any one please help me

regards
Antony

drfunk2458 wrote:
did you try using the "/privatekey=" option ??
tsantony
[View user's profile]
Donor
Joined: 2013-01-04
Posts: 12
Hi,

i'm receiving the following error.

Information: 21/Jan/2013 10:16:04 Searching for host...
Information: 21/Jan/2013 10:16:04 Connecting to host...
Information: 21/Jan/2013 10:16:04 Authenticating...
Information: 21/Jan/2013 10:16:04 The server's host key was not found in the cache. You have no guarantee that the server is the computer you think it is.
Information: 21/Jan/2013 10:16:04 The server's rsa2 key fingerprint is:
Information: 21/Jan/2013 10:16:04 ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.....
Information: 21/Jan/2013 10:16:04 Connection : open sftp://sftpmazda@xxx.xxx.xxx.xxx:xxxxx -hostKey="ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx....."
Error: 21/Jan/2013 10:16:06 Connection has been unexpectedly closed. Server sent command exit status 0.
Error: 21/Jan/2013 10:16:06 Authentication log (see session log for details):
Using username "sftpmazda".
Access denied.

Error: 21/Jan/2013 10:16:06 Authentication failed.

please help me

regards
Antony


prikryl wrote:
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
Please read:
http://winscp.net/eng/docs/scripting#hostkey

If that does not help, attach a full log file showing the problem (using the latest version of WinSCP).

To generate log file, use /log=path_to_log_file command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you may email it to me. You will find my address (if you log in) in my forum profile. Please include link back to this topic in your email. Also note in this topic that you have emailed the log.
tsantony
[View user's profile]
Donor
Joined: 2013-01-04
Posts: 12
Hi,

thanks a lot, i fund the answer.

i have include the /privatekey and /hostkey, then i got the answer

thanks again Very Happy

regards,
Antony

prikryl wrote:
Please read:
http://winscp.net/eng/docs/scripting#hostkey

If that does not help, attach a full log file showing the problem (using the latest version of WinSCP).

To generate log file, use /log=path_to_log_file command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you may email it to me. You will find my address (if you log in) in my forum profile. Please include link back to this topic in your email. Also note in this topic that you have emailed the log.
Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy
tsantony
[View user's profile]
Donor
Joined: 2013-01-04
Posts: 12
Hi,

i want to capture only "Network" related errors. may i know how i can do this?

thanks advance.

regards,
Antony.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
tsantony wrote:
i want to capture only "Network" related errors. may i know how i can do this?

This is not supported.
tsantony
[View user's profile]
Donor
Joined: 2013-01-04
Posts: 12
Hi,

thanks for your reply.
but i found the way to capture the Network ERRORs.

process.ExitCode <> 0

regards,
Antony

prikryl wrote:
tsantony wrote:
i want to capture only "Network" related errors. may i know how i can do this?

This is not supported.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
That captures any error, not only network errors.
_________________
Martin Prikryl
tsantony
[View user's profile]
Donor
Joined: 2013-01-04
Posts: 12
Hi,

i'm testing my app. i'll let you know. once i have done.

prikryl wrote:
That captures any error, not only network errors.
samk3nny

Guest


I am seeing the same error but within Powershell.

I have set the following but keep getting the message "Host key wasn't verified!". I am assuming it is something related to the setting of my session options. If I use the ppk file and login details below through the GUI, it works fine. I also tried using a .ini file and putting that both where winscp is run from and where the Powershell script, but with no luck.

Any ideas?

Thanks,
Sam


# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$sessionOptions.HostName = "sftp.site.com"
$sessionOptions.UserName = "my_login"
#$sessionOptions.Password = "mypassword"
$sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
$sessionOptions.SshHostKey = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
$sessionOptions.SshPrivateKeyPath = "\\Path\to\File"
$sessionOptions.SshPrivateKey = "myfile.ppk"
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
samk3nny wrote:
I am seeing the same error but within Powershell.

I have set the following but keep getting the message "Host key wasn't verified!". I am assuming it is something related to the setting of my session options. If I use the ppk file and login details below through the GUI, it works fine. I also tried using a .ini file and putting that both where winscp is run from and where the Powershell script, but with no luck.

Please attach a complete session log file (set Session.SessionLogFile). Please note that public host key is not a secret information.

Also (not related to your problem):
SshHostKey is obsolete name of SshHostKeyFingerprint. No point setting both.
SshPrivateKey is obsolete name of SshPrivateKeyPath. No point setting both. Either should contain full path (folder path and filename).
_________________
Martin Prikryl
vibs

Guest


you need to add the hostkey in the commandline

http://etlexperts.blogspot.com/2015/10/winscp-host-key-wasn-verified.html
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