Host Key Not Configured

Advertisement

Gorphus22
Guest

Host Key Not Configured

I am trying to create a scheduled task to upload and delete some files. I am getting a host key error when calling my script from a batch file. However if I open WinSCP.com and paste each line in individually, they all work flawlessly. I added the -hostkey=* to my open command and it still says there is a host key error.
Batch File
"C:\WinSCP\winscp.com" /script=filename.txt /log=brwinscp.log /ini=nul
Script
open sftp://brftp:workingpassword@serverIP:2222 -hostkey=*
put -delete c:\FTP\brftp\FileNameID_* /
exit
Error Log
. 2023-01-09 15:23:01.217 Remote version: SSH-2.0-CrushFTPSSHD
. 2023-01-09 15:23:01.218 Using SSH protocol version 2
. 2023-01-09 15:23:01.282 Doing ECDH key exchange with curve Curve25519 and hash SHA-256
. 2023-01-09 15:23:01.761 Server also has rsa-sha2-256/ssh-rsa/ssh-dss host keys, but we don't know any of them
. 2023-01-09 15:23:01.761 Host key fingerprint is:
. 2023-01-09 15:23:01.761 ssh-rsa 4096 SHA256:KQU3bUJpxEZzhK9JunBzk/2P8fLL6RLlRkBBzrLyqzY
< 2023-01-09 15:23:01.761 Script: Authenticating...
. 2023-01-09 15:23:01.762 Attempt to close connection due to fatal exception:
* 2023-01-09 15:23:01.762 Host key fingerprint is ssh-rsa 4096 KQU3bUJpxEZzhK9JunBzk/2P8fLL6RLlRkBBzrLyqzY.
* 2023-01-09 15:23:01.762 (Exception) **Expected host key was not configured, use -hostkey switch.**
. 2023-01-09 15:23:01.762 Closing connection.
< 2023-01-09 15:23:01.764 Script: Expected host key was not configured, use -hostkey switch.
< 2023-01-09 15:23:01.764 Host key fingerprint is ssh-rsa 4096 KQU3bUJpxEZzhK9JunBzk/2P8fLL6RLlRkBBzrLyqzY.

Reply with quote

Advertisement

gorphus22
Guest

Host Key Not Configured

2023-01-09 15:23:01.131 WinSCP Version 5.21.6 (Build 12913 2022-11-28) (OS 10.0.19045 - Windows 10 Enterprise)
. 2023-01-09 15:23:01.131 Configuration: nul
. 2023-01-09 15:23:01.131 Log level: Normal
. 2023-01-09 15:23:01.131 Local account: DESKTOP-VMLL1MT\jpray
. 2023-01-09 15:23:01.131 Working directory: C:\WinSCP\Scripts
. 2023-01-09 15:23:01.131 Process ID: 9060
. 2023-01-09 15:23:01.179 Ancestor processes: WinSCP, cmd, explorer, ...
. 2023-01-09 15:23:01.180 Command-line: "C:\WinSCP\WinSCP.exe" /console=5.21.6 /consoleinstance=_6696_795 "/script=script.txt" "/log=brwinscp.log" "/ini=nul" 
. 2023-01-09 15:23:01.180 Time zone: Current: GMT-6, Standard: GMT-6 (Central Standard Time), DST: GMT-5 (Central Daylight Time), DST Start: 3/12/2023, DST End: 11/5/2023
. 2023-01-09 15:23:01.181 Login time: Monday, January 9, 2023 3:23:01 PM
. 2023-01-09 15:23:01.181 --------------------------------------------------------------------------
. 2023-01-09 15:23:01.181 Script: Retrospectively logging previous script records:
> 2023-01-09 15:23:01.181 Script: open sftp://cs_br:***@serverIP:2222
. 2023-01-09 15:23:01.181 --------------------------------------------------------------------------
. 2023-01-09 15:23:01.181 Session name: cs_br@serverIP (Ad-Hoc site)
. 2023-01-09 15:23:01.181 Host name: serverIP (Port: 2222)
. 2023-01-09 15:23:01.181 User name: cs_br (Password: Yes, Key file: No, Passphrase: No)
. 2023-01-09 15:23:01.181 Tunnel: No
. 2023-01-09 15:23:01.181 Transfer Protocol: SFTP
. 2023-01-09 15:23:01.181 Ping type: Off, Ping interval: 30 sec; Timeout: 15 sec
. 2023-01-09 15:23:01.181 Disable Nagle: No
. 2023-01-09 15:23:01.182 Proxy: None
. 2023-01-09 15:23:01.182 Send buffer: 262144
. 2023-01-09 15:23:01.182 Compression: No
. 2023-01-09 15:23:01.182 Bypass authentication: No
. 2023-01-09 15:23:01.182 Try agent: Yes; Agent forwarding: No; KI: Yes; GSSAPI: Yes
. 2023-01-09 15:23:01.182 GSSAPI: KEX: No; Forwarding: No; Libs: gssapi32,sspi,custom; Custom: 
. 2023-01-09 15:23:01.182 Ciphers: aes,chacha20,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2023-01-09 15:23:01.182 KEX: ecdh,dh-gex-sha1,dh-group14-sha1,rsa,WARN,dh-group1-sha1
. 2023-01-09 15:23:01.182 SSH Bugs: Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto
. 2023-01-09 15:23:01.182 Simple channel: Yes
. 2023-01-09 15:23:01.182 Return code variable: Autodetect; Lookup user groups: Auto
. 2023-01-09 15:23:01.182 Shell: default
. 2023-01-09 15:23:01.182 EOL: LF, UTF: Auto
. 2023-01-09 15:23:01.182 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes; Follow directory symlinks: No
. 2023-01-09 15:23:01.182 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No; Exit code 1 is error: No
. 2023-01-09 15:23:01.182 SFTP Bugs: Auto,Auto
. 2023-01-09 15:23:01.183 SFTP Server: default
. 2023-01-09 15:23:01.183 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2023-01-09 15:23:01.183 Cache directory changes: Yes, Permanent: Yes
. 2023-01-09 15:23:01.183 Recycle bin: Delete to: No, Overwritten to: No, Bin path: 
. 2023-01-09 15:23:01.183 DST mode: Unix
. 2023-01-09 15:23:01.183 --------------------------------------------------------------------------
< 2023-01-09 15:23:01.183 Script: Searching for host...
. 2023-01-09 15:23:01.187 Looking up host "169.46.47.16" for SSH connection
. 2023-01-09 15:23:01.187 Connecting to serverIP port 2222
. 2023-01-09 15:23:01.204 Connected to serverIP
< 2023-01-09 15:23:01.205 Script: Connecting to host...
. 2023-01-09 15:23:01.208 We claim version: SSH-2.0-WinSCP_release_5.21.6
. 2023-01-09 15:23:01.208 Connected to serverIP
. 2023-01-09 15:23:01.217 Remote version: SSH-2.0-CrushFTPSSHD
. 2023-01-09 15:23:01.218 Using SSH protocol version 2
. 2023-01-09 15:23:01.282 Doing ECDH key exchange with curve Curve25519 and hash SHA-256
. 2023-01-09 15:23:01.761 Server also has rsa-sha2-256/ssh-rsa/ssh-dss host keys, but we don't know any of them
. 2023-01-09 15:23:01.761 Host key fingerprint is:
. 2023-01-09 15:23:01.761 ssh-rsa 4096 SHA256:KQU3bUJpxEZzhK9JunBzk/2P8fLL6RLlRkBBzrLyqzY
< 2023-01-09 15:23:01.761 Script: Authenticating...
. 2023-01-09 15:23:01.762 Attempt to close connection due to fatal exception:
* 2023-01-09 15:23:01.762 Host key fingerprint is ssh-rsa 4096 KQU3bUJpxEZzhK9JunBzk/2P8fLL6RLlRkBBzrLyqzY.
* 2023-01-09 15:23:01.762 (Exception) **Expected host key was not configured, use -hostkey switch.**
. 2023-01-09 15:23:01.762 Closing connection.
< 2023-01-09 15:23:01.764 Script: Expected host key was not configured, use -hostkey switch.
< 2023-01-09 15:23:01.764 Host key fingerprint is ssh-rsa 4096 KQU3bUJpxEZzhK9JunBzk/2P8fLL6RLlRkBBzrLyqzY.
 
< 2023-01-09 15:23:01.764 Authentication failed.

Reply with quote

Mister H
Guest

In your script try changing -hostkey like so:
open sftp://brftp:workingpassword@serverIP:2222 -hostkey="ecdsa-sha2-nistp256 256 KQU3bUJpxEZzhK9JunBzk/2P8fLL6RLlRkBBzrLyqzY"
YMMV

Reply with quote

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

Re: Host Key Not Configured

@gorphus22: Your script does not contain any -hostkey switch:
open sftp://cs_br:***@serverIP:2222
Make sure you are editing the right file. Note that the working directory of your script is C:\WinSCP\Scripts. So the /script=script.txt refers to the C:\WinSCP\Scripts\script.txt.

Reply with quote

Advertisement

You can post new topics in this forum