WinSCP connecting to CoreFTP – Server’s Host Key is Invalid

sftpwinscp

I created a key with PuttyGen as shown below (and saved private and public key files):

enter image description here

I then used that key in CoreFTP setup:
enter image description here
I stopped/restarted CoreFTP.

I am able to Telnet to port 22 from the client machine.

I used the private key on the Advanced: SSH/Authentication "Private Key File" in WinSCP.

When I try to connect, WinSCP says "Server's host key is invalid".
CoreFTP only shows two lines:

connected
disconnected() 

Also, I can't get any log file to be created from CoreFTP, even though I turned all logging on and gave it a file name.

In WinSCP, I also did a Tools/Cleanup and checked "Cahed host keys" and "Temporary Folders". I did a fresh install FileZilla client, and gives same erorr "Server's host key is invalid". So this indicates problem is on the server, not the client.

Was reading this post, but I cannot find any place in CoreFTP to specify a host private/public key pair. It does have a place for a certificate though.

I found this, which may be the source of the issue, but not sure how to correct it:
enter image description here
It was self-genereated with SHA and 2048 bits.

Client logs:

WinSCP
. 2019-05-22 09:34:56.009 Looking up host "x.x.x.x" for SSH connection
. 2019-05-22 09:34:56.009 Connecting to x.x.x.x port 22
. 2019-05-22 09:34:56.013 We claim version: SSH-2.0-WinSCP_release_5.15.1
. 2019-05-22 09:34:56.026 Server version: SSH-2.0-CoreFTP-0.3.3
. 2019-05-22 09:34:56.026 Using SSH protocol version 2
. 2019-05-22 09:34:56.030 Doing Diffie-Hellman group exchange
. 2019-05-22 09:34:56.033 Doing Diffie-Hellman key exchange with hash SHA-256
. 2019-05-22 09:34:56.724 Server's host key is invalid
* 2019-05-22 09:34:56.770 (EFatal) Server's host key is invalid

SmartFTP
2019-05-22T14:28:47Z Resolving host name "x.x.x.x"
2019-05-22T14:28:47Z Connecting to x.x.x.x Port: 22
2019-05-22T14:28:47Z Connected to x.x.x.x.
2019-05-22T14:28:47Z SSH protocol version reply. Client Id: SSH-2.0-SmartFTP
2019-05-22T14:28:47Z SSH-2.0-CoreFTP-0.3.3
2019-05-22T14:28:47Z Starting SSH session. Remote Id: "SSH-2.0-CoreFTP-0.3.3"
2019-05-22T14:28:47Z Server Algorithm Suite
Key Exchange: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256
Server Host Key: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-dss,ecdsa-sha2-nistp521
Client to Server Encryption: aes128-ctr,aes192-ctr,aes256-ctr
Server to Client Encryption: aes128-ctr,aes192-ctr,aes256-ctr
Client to Server HMAC: hmac-sha2-256,hmac-sha2-512,hmac-sha2-384,hmac-sha1
Server to Client HMAC: hmac-sha2-256,hmac-sha2-512,hmac-sha2-384,hmac-sha1
Client to Server Compression: none,none
Server to Client Compression: none,none
2019-05-22T14:28:47Z Selected Algorithm Suite
Key Exchange: diffie-hellman-group-exchange-sha256
Server Host Key: ecdsa-sha2-nistp521
Client to Server Encryption: aes128-ctr
Server to Client Encryption: aes128-ctr
Client to Server HMAC: hmac-sha1
Server to Client HMAC: hmac-sha1
Client to Server Compression: none
Server to Client Compression: none
2019-05-22T14:28:47Z Client Algorithm Suite
Key Exchange: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp521,ecdh-sha2-nistp384,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,ext-info-c
Server Host Key: ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-256,rsa-sha2-512,ssh-rsa,x509v3-ecdsa-sha2-nistp256,x509v3-ecdsa-sha2-nistp384,x509v3-ecdsa-sha2-nistp521,x509v3-rsa2048-sha256,x509v3-ssh-rsa
Client to Server Encryption: aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
Server to Client Encryption: aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
Client to Server HMAC: hmac-sha1,hmac-sha2-256,hmac-sha2-512
Server to Client HMAC: hmac-sha1,hmac-sha2-256,hmac-sha2-512
Client to Server Compression: zlib@openssh.com,none
Server to Client Compression: zlib@openssh.com,none
2019-05-22T14:28:47Z Key Exchange Algorithm: diffie-hellman-group-exchange-sha256
2019-05-22T14:28:47Z Invalid host key.
2019-05-22T14:28:47Z Exception. Error=0x80072745

Best Answer

This a fail-safe mechanism built into SFTP and SSH to prevent man-in-the-middle attacks. You must verify and accept the server's certificate before the secure transfer can start.

If you are using the WinSCP command line utilities, you can use the /hostkey argument to specify the fingerprint of the CoreFTP server so it will automatically start the transfer without prompting.

Another option is to log in as the user who will be running the script, then establish a connection using the winscp command line. It should prompt you to accept the servers's key and keep this in user settings.

If you change servers, you will have to remember to re-trust, or update the client's settings of /hostkey.

Related Topic