Getting and error with host key...

Advertisement

henryga
Joined:
Posts:
1
Location:
Virginia

Getting and error with host key...

Hello.

First thank you in advance for any help... I am pretty new with scripting and I do not use it much so this may be a simple question so if it is I am sorry...

I had this script working but I had to replace a piece of equipment so I needed to update the U/P and the host key and now it does not work

I start WinSCP from a batch file called CloudBackup in the script it runs this command
"C:\Program Files (x86)\WinSCP\WinSCP.exe" /log="C:\UnifiBackup\Ace\aceWinSCP.log" /ini=nul /script="C:\UnifiBackup\AceCloudkey.scr"
The acecloudlkey.scr looks like this – User and passwords removed
open sftp://<username>:<password>@192.168.0.11/ -hostkey="ssh-ed25519 255 ssh-ed25519 255 2Vhr2lmNwE1Cr268BUQhb4Ru4vgnQHxsPw0ZPfDKQaA="
cd /data/autobackup
binary
get * "C:\Users\mandgphoto\OneDrive\Unifi Backups\ace\ACE_*"
If I manually logon to WinSCP and paste the above script into the screen it works just fine and authenticates as you see from my screen...
winscp> open sftp://<username>:<password>@192.168.0.11/ -hostkey="ssh-ed25519 255 ssh-ed25519 255 2Vhr2lmNwE1Cr268BUQhb4Ru4vgnQHxsPw0ZPfDKQaA="
Searching for host...
Connecting to host...
Authenticating...
Using username "root".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Session started.
Active session: [1] root@192.168.0.11
winscp> cd /data/autobackup

If I run my script and I look at the log file it fails and the log file looks like this
. 2022-04-16 14:47:50.432 Looking up host "192.168.0.11" for SSH connection
. 2022-04-16 14:47:50.433 Connecting to 192.168.0.11 port 22
. 2022-04-16 14:47:50.464 We claim version: SSH-2.0-WinSCP_release_5.17.9
. 2022-04-16 14:47:50.522 Remote version: SSH-2.0-OpenSSH_7.4p1 Debian-10+deb9u7
. 2022-04-16 14:47:50.522 Using SSH protocol version 2
. 2022-04-16 14:47:50.522 Have a known host key of type ssh-ed25519
. 2022-04-16 14:47:50.556 Doing ECDH key exchange with curve Curve25519 and hash SHA-256
. 2022-04-16 14:47:50.675 Server also has ecdsa-sha2-nistp256/ssh-rsa host keys, but we don't know any of them
. 2022-04-16 14:47:50.675 Host key fingerprint is:
. 2022-04-16 14:47:50.675 ssh-ed25519 255 4f:47:5b:b5:7b:c8:eb:fb:8d:95:3c:0a:c4:70:87:fc 2Vhr2lmNwE1Cr268BUQhb4Ru4vgnQHxsPw0ZPfDKQaA=
[color=red]. 2022-04-16 14:47:50.675 Host key does not match configured key fingerprint ssh-ed25519 255 ssh-ed25519 255 2Vhr2lmNwE1Cr268BUQhb4Ru4vgnQHxsPw0ZPfDKQaA=[/color]
. 2022-04-16 14:47:50.675 Attempt to close connection due to fatal exception:
* 2022-04-16 14:47:50.675 Host key fingerprint is ssh-ed25519 255 2Vhr2lmNwE1Cr268BUQhb4Ru4vgnQHxsPw0ZPfDKQaA=.
* 2022-04-16 14:47:50.675 (Exception) **Host key does not match configured key fingerprint "ssh-ed25519 255 ssh-ed25519 255 2Vhr2lmNwE1Cr268BUQhb4Ru4vgnQHxsPw0ZPfDKQaA="!**
. 2022-04-16 14:47:50.675 Closing connection.
I just do not understand why the host key can validate if I run the script manually but does not work if I run it through the script.

Please help me
Thanks
Gary

Reply with quote

Advertisement

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

Re: Getting and error with host key...

You have ssh-ed25519 255 twice in
-hostkey="ssh-ed25519 255 ssh-ed25519 255 2Vhr2lmNwE1Cr268BUQhb4Ru4vgnQHxsPw0ZPfDKQaA="
It should be just
-hostkey="ssh-ed25519 255 2Vhr2lmNwE1Cr268BUQhb4Ru4vgnQHxsPw0ZPfDKQaA="
It works in GUI, because GUI probably has the correct host key cached, so it verifies the host key against the cache, when it fails to do so using the fingerprint from the script.

Reply with quote

Advertisement

You can post new topics in this forum