Couldn't agree a host key algorithm error in batch but not GUI

Advertisement

AmyMorgan9
Joined:
Posts:
2
Location:
Naples, Florida

Couldn't agree a host key algorithm error in batch but not GUI

Using the WinSCP GUI, I can authenticate to the host I am trying to transfer a file to and the file transfer is successful. The first time connecting I accepted the host key. I see the host key in the registry. Of all the connections I have, it is the only connection using ssh-ed25519.

When I create a script file and run the batch file I receive the following error in the batch log file:

NOTE : I am XXX-ing out sensitive information with user name, passwords, IPs in all log files.
. 2025-01-16 10:15:36.443 Looking up host "XXX.XX.XXX.XX"
. 2025-01-16 10:15:36.443 Connecting to XXX.XX.XXX.XX port 22
. 2025-01-16 10:15:36.537 Server version: SSH-2.0-OpenSSH_8.7
. 2025-01-16 10:15:36.537 Using SSH protocol version 2
. 2025-01-16 10:15:36.537 We claim version: SSH-2.0-WinSCP_release_5.7.6
. 2025-01-16 10:15:36.568 Couldn't agree a host key algorithm (available: rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519)
Another interesting note at the beginning of the log file it says this:
. 2025-01-16 10:15:36.443 WinSCP Version 5.7.6 (Build 5874) (OS 10.0.17763 - Windows Server 2019 Datacenter)
. 2025-01-16 10:15:36.443 Configuration: C:\WinSCP\winscp.ini
Which I find interesting because I am running the latest version of WinSCP (6.3.6)

The log file from WinSCP located in %TEMP% says this about my successful connection using the GUI (note that it lists the correct version of WinSCP):
. 2025-01-16 12:10:17.281 --------------------------------------------------------------------------
. 2025-01-16 12:10:17.281 WinSCP Version 6.3.6 (Build 15073 2024-11-25) (OS 10.0.17763 – Windows Server 2019 Datacenter)
. 2025-01-16 12:10:17.281 Configuration: HKCU\Software\Martin Prikryl\WinSCP 2\
. 2025-01-16 12:10:17.281 Log level: Normal
. 2025-01-16 12:10:17.281 Local account: XXXX
. 2025-01-16 12:10:17.281 Working directory: C:\Program Files (x86)\WinSCP
. 2025-01-16 12:10:17.281 Process ID: 7108
. 2025-01-16 12:10:17.281 Ancestor processes: explorer, ...
. 2025-01-16 12:10:17.281 Command-line: "C:\Program Files (x86)\WinSCP\WinSCP.exe" 
. 2025-01-16 12:10:17.281 Time zone: Current: GMT-5, Standard: GMT-5 (Eastern Standard Time), DST: GMT-4 (Eastern Daylight Time), DST Start: 3/9/2025, DST End: 11/2/2025
. 2025-01-16 12:10:17.281 Login time: Thursday, January 16, 2025 12:10:17 PM
. 2025-01-16 12:10:17.281 --------------------------------------------------------------------------
. 2025-01-16 12:10:17.281 Session name: XXX (Site)
. 2025-01-16 12:10:17.281 Host name: XXX (Port: 22)
. 2025-01-16 12:10:17.281 User name: XX (Password: Yes, Key file: No, Passphrase: No)
. 2025-01-16 12:10:17.281 Tunnel: No
. 2025-01-16 12:10:17.281 Transfer Protocol: SFTP (SCP)
. 2025-01-16 12:10:17.281 Ping type: Off, Ping interval: 30 sec; Timeout: 15 sec
. 2025-01-16 12:10:17.281 Disable Nagle: No
. 2025-01-16 12:10:17.281 Proxy: None
. 2025-01-16 12:10:17.281 Send buffer: 262144
. 2025-01-16 12:10:17.281 Compression: No
. 2025-01-16 12:10:17.281 Bypass authentication: No
. 2025-01-16 12:10:17.281 Try agent: Yes; Agent forwarding: No; KI: Yes; GSSAPI: Yes
. 2025-01-16 12:10:17.281 GSSAPI: KEX: No; Forwarding: No; Libs: gssapi32,sspi,custom; Custom: 
. 2025-01-16 12:10:17.281 Ciphers: aes,chacha20,aesgcm,3des,WARN,des,blowfish,arcfour; Ssh2DES: No
. 2025-01-16 12:10:17.281 KEX: ntru-curve25519,ecdh,dh-gex-sha1,dh-group18-sha512,dh-group17-sha512,dh-group16-sha512,dh-group15-sha512,dh-group14-sha1,rsa,WARN,dh-group1-sha1
. 2025-01-16 12:10:17.281 SSH Bugs: Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto
. 2025-01-16 12:10:17.281 Simple channel: Yes
. 2025-01-16 12:10:17.281 Return code variable: Autodetect; Lookup user groups: Auto
. 2025-01-16 12:10:17.281 Shell: default
. 2025-01-16 12:10:17.281 EOL: LF, UTF: Auto
. 2025-01-16 12:10:17.281 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes; Follow directory symlinks: No
. 2025-01-16 12:10:17.281 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No; Exit code 1 is error: No
. 2025-01-16 12:10:17.281 SFTP Bugs: Auto,Auto
. 2025-01-16 12:10:17.281 SFTP Server: default
. 2025-01-16 12:10:17.281 Local directory: C:\WinSCP\ToCCPS, Remote directory: /upload, Update: Yes, Cache: Yes
. 2025-01-16 12:10:17.281 Cache directory changes: Yes, Permanent: Yes
. 2025-01-16 12:10:17.281 Recycle bin: Delete to: No, Overwritten to: No, Bin path: 
. 2025-01-16 12:10:17.281 DST mode: Unix
. 2025-01-16 12:10:17.281 --------------------------------------------------------------------------
. 2025-01-16 12:10:17.297 Looking up host "XXX.XX.XXX.XX" for SSH connection
. 2025-01-16 12:10:17.297 Connecting to XXX.XX.XXX.XX port 22
. 2025-01-16 12:10:17.344 Connected to XXX.XX.XXX.XX
. 2025-01-16 12:10:17.359 We claim version: SSH-2.0-WinSCP_release_6.3.6
. 2025-01-16 12:10:17.359 Connected to XXX.XX.XXX.XX
. 2025-01-16 12:10:17.391 Remote version: SSH-2.0-OpenSSH_8.7
. 2025-01-16 12:10:17.391 Using SSH protocol version 2
. 2025-01-16 12:10:17.391 Have a known host key of type ssh-ed25519
. 2025-01-16 12:10:17.438 Doing ECDH key exchange with curve Curve25519, using hash SHA-256
. 2025-01-16 12:10:17.516 Server also has ecdsa-sha2-nistp256/rsa-sha2-512/rsa-sha2-256 host keys, but we don't know any of them
. 2025-01-16 12:10:17.516 Host key fingerprint is:
. 2025-01-16 12:10:17.516 ssh-ed25519 255 SHA256:XXX
. 2025-01-16 12:10:17.547 Host key matches cached key
. 2025-01-16 12:10:17.547 Initialised AES-256 SDCTR (AES-NI accelerated) [aes256-ctr] outbound encryption
. 2025-01-16 12:10:17.547 Initialised HMAC-SHA-256 outbound MAC algorithm
. 2025-01-16 12:10:17.547 Initialised AES-256 SDCTR (AES-NI accelerated) [aes256-ctr] inbound encryption
. 2025-01-16 12:10:17.547 Initialised HMAC-SHA-256 inbound MAC algorithm
! 2025-01-16 12:10:17.578 Using username "XXXX".
. 2025-01-16 12:10:17.625 Server offered these authentication methods: publickey,gssapi-keyex,gssapi-with-mic,password
. 2025-01-16 12:10:17.625 Using SSPI from SECUR32.DLL
. 2025-01-16 12:10:17.625 Trying gssapi-with-mic...
. 2025-01-16 12:10:17.625 Attempting GSSAPI authentication
. 2025-01-16 12:10:17.672 GSSAPI authentication request refused
. 2025-01-16 12:10:17.672 Server offered these authentication methods: publickey,gssapi-keyex,gssapi-with-mic,password
. 2025-01-16 12:10:17.672 Prompt (password, "SSH password", <no instructions>, "&Password: ")
. 2025-01-16 12:10:17.672 Using stored password.
. 2025-01-16 12:10:17.719 Sent password
. 2025-01-16 12:10:17.859 Access granted
. 2025-01-16 12:10:17.859 Opening main session channel
. 2025-01-16 12:10:18.188 Opened main channel
. 2025-01-16 12:10:18.219 Started a shell/command
. 2025-01-16 12:10:18.281 --------------------------------------------------------------------------
. 2025-01-16 12:10:18.281 Using SFTP protocol.
. 2025-01-16 12:10:18.281 Doing startup conversation with host.
> 2025-01-16 12:10:18.297 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2025-01-16 12:10:18.328 Type: SSH_FXP_VERSION, Size: 238, Number: -1
. 2025-01-16 12:10:18.328 SFTP version 3 negotiated.
. 2025-01-16 12:10:18.328 Supports extension posix-rename@openssh.com="1"
. 2025-01-16 12:10:18.328 Supports statvfs@openssh.com extension version 2
. 2025-01-16 12:10:18.328 Unknown server extension fstatvfs@openssh.com="2"
. 2025-01-16 12:10:18.328 Supports hardlink@openssh.com extension version 1
. 2025-01-16 12:10:18.328 Unknown server extension fsync@openssh.com="1"
. 2025-01-16 12:10:18.328 Unknown server extension lsetstat@openssh.com="1"
. 2025-01-16 12:10:18.328 Supports limits@openssh.com extension version 1
. 2025-01-16 12:10:18.328 Unknown server extension expand-path@openssh.com="1"
. 2025-01-16 12:10:18.328 We believe the server has signed timestamps bug
. 2025-01-16 12:10:18.328 We will use UTF-8 strings until server sends an invalid UTF-8 string as with SFTP version 3 and older UTF-8 strings are not mandatory
> 2025-01-16 12:10:18.328 Type: SSH_FXP_EXTENDED, Size: 27, Number: 200
< 2025-01-16 12:10:18.360 Type: SSH_FXP_EXTENDED_REPLY, Size: 37, Number: 200
. 2025-01-16 12:10:18.360 Limiting packet size to server's limit of 262144 + 4 bytes
. 2025-01-16 12:10:18.360 Changing directory to "/upload".
. 2025-01-16 12:10:18.360 Getting real path for '/upload'
> 2025-01-16 12:10:18.360 Type: SSH_FXP_REALPATH, Size: 16, Number: 272
< 2025-01-16 12:10:18.391 Type: SSH_FXP_NAME, Size: 35, Number: 272
. 2025-01-16 12:10:18.391 Real path is '/upload'
. 2025-01-16 12:10:18.391 Trying to open directory "/upload".
> 2025-01-16 12:10:18.391 Type: SSH_FXP_LSTAT, Size: 16, Number: 519
< 2025-01-16 12:10:18.438 Type: SSH_FXP_ATTRS, Size: 37, Number: 519
. 2025-01-16 12:10:18.438 Getting current directory name.
. 2025-01-16 12:10:18.516 Listing directory "/upload".
> 2025-01-16 12:10:18.516 Type: SSH_FXP_OPENDIR, Size: 16, Number: 779
< 2025-01-16 12:10:18.547 Type: SSH_FXP_HANDLE, Size: 13, Number: 779
> 2025-01-16 12:10:18.547 Type: SSH_FXP_READDIR, Size: 13, Number: 1036
< 2025-01-16 12:10:18.578 Type: SSH_FXP_NAME, Size: 207, Number: 1036
> 2025-01-16 12:10:18.578 Type: SSH_FXP_READDIR, Size: 13, Number: 1292
< 2025-01-16 12:10:18.610 Type: SSH_FXP_STATUS, Size: 28, Number: 1292
< 2025-01-16 12:10:18.610 Status code: 1
> 2025-01-16 12:10:18.610 Type: SSH_FXP_CLOSE, Size: 13, Number: 1540
. 2025-01-16 12:10:18.610 ..;d;0;2025-01-08T21:06:53.000Z;4;"root" [0];"1001" [1001];rwxr-xr-x;0
. 2025-01-16 12:10:18.656 Startup conversation with host finished.
. 2025-01-16 12:10:21.500 Copying 1 files/directories to remote directory "/upload/" - total size: 1,327,748
. 2025-01-16 12:10:21.500   PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: S (102400); CalcS: Yes; Mask: *.*
. 2025-01-16 12:10:21.500   TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; EncryptNewFiles: Yes; ExcludeHiddenFiles: No; ExcludeEmptyDirectories: No; InclM: ; ResumeL: 0
. 2025-01-16 12:10:21.500   AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2025-01-16 12:10:21.500 File: 'C:\WinSCP\ToCCPS\School_checks2.xlsx' [2025-01-15T18:50:08.498Z] [1327748]
. 2025-01-16 12:10:21.500 Copying "C:\WinSCP\ToCCPS\School_checks2.xlsx" to remote directory started.
. 2025-01-16 12:10:21.500 Binary transfer mode selected.
. 2025-01-16 12:10:21.500 Checking existence of file.
> 2025-01-16 12:10:21.500 Type: SSH_FXP_LSTAT, Size: 36, Number: 1799
< 2025-01-16 12:10:21.500 Type: SSH_FXP_STATUS, Size: 24, Number: 1540
. 2025-01-16 12:10:21.500 Discarding reserved response
< 2025-01-16 12:10:21.532 Type: SSH_FXP_STATUS, Size: 29, Number: 1799
< 2025-01-16 12:10:21.532 Status code: 2
. 2025-01-16 12:10:21.532 Checking existence of partially transferred file.
> 2025-01-16 12:10:21.532 Type: SSH_FXP_LSTAT, Size: 45, Number: 2055
< 2025-01-16 12:10:21.563 Type: SSH_FXP_STATUS, Size: 29, Number: 2055
< 2025-01-16 12:10:21.563 Status code: 2
. 2025-01-16 12:10:21.563 Opening remote file.
> 2025-01-16 12:10:21.563 Type: SSH_FXP_OPEN, Size: 61, Number: 2307
< 2025-01-16 12:10:21.594 Type: SSH_FXP_HANDLE, Size: 13, Number: 2307
> 2025-01-16 12:10:21.594 Type: SSH_FXP_WRITE, Size: 32761, Number: 2822
. 2025-01-16 12:10:21.672 Skipped 14 SSH_FXP_WRITE packets
< 2025-01-16 12:10:21.672 Type: SSH_FXP_STATUS, Size: 24, Number: 2822
< 2025-01-16 12:10:21.672 Status code: 0
. 2025-01-16 12:10:21.813 Increasing send buffer from 262144 to 524288
. 2025-01-16 12:10:21.813 Skipped 26 SSH_FXP_WRITE and 13 SSH_FXP_STATUS packets
> 2025-01-16 12:10:21.813 Type: SSH_FXP_CLOSE, Size: 13, Number: 13316
. 2025-01-16 12:10:21.876 Skipped 27 SSH_FXP_STATUS packets
< 2025-01-16 12:10:21.876 Type: SSH_FXP_STATUS, Size: 24, Number: 13316
< 2025-01-16 12:10:21.876 Status code: 0
> 2025-01-16 12:10:21.876 Type: SSH_FXP_RENAME, Size: 76, Number: 13586
< 2025-01-16 12:10:21.907 Type: SSH_FXP_STATUS, Size: 24, Number: 13586
< 2025-01-16 12:10:21.907 Status code: 0
. 2025-01-16 12:10:21.907 Preserving timestamp [2025-01-15T18:50:08.000Z]
> 2025-01-16 12:10:21.907 Type: SSH_FXP_SETSTAT, Size: 48, Number: 2569
< 2025-01-16 12:10:21.954 Type: SSH_FXP_STATUS, Size: 24, Number: 2569
< 2025-01-16 12:10:21.954 Status code: 0
. 2025-01-16 12:10:21.954 Transfer done: 'C:\WinSCP\ToCCPS\School_checks2.xlsx' => '/upload/School_checks2.xlsx' [1327748]
. 2025-01-16 12:10:21.954 Copying finished: Transferred: 1,327,748, Elapsed: 0:00:00, CPS: 2,573,155/s
. 2025-01-16 12:10:21.954 Listing directory "/upload".
> 2025-01-16 12:10:21.954 Type: SSH_FXP_OPENDIR, Size: 16, Number: 13835
< 2025-01-16 12:10:21.985 Type: SSH_FXP_HANDLE, Size: 13, Number: 13835
> 2025-01-16 12:10:21.985 Type: SSH_FXP_READDIR, Size: 13, Number: 14092
< 2025-01-16 12:10:22.016 Type: SSH_FXP_NAME, Size: 341, Number: 14092
> 2025-01-16 12:10:22.016 Type: SSH_FXP_READDIR, Size: 13, Number: 14348
< 2025-01-16 12:10:22.047 Type: SSH_FXP_STATUS, Size: 28, Number: 14348
< 2025-01-16 12:10:22.079 Status code: 1
> 2025-01-16 12:10:22.079 Type: SSH_FXP_CLOSE, Size: 13, Number: 14596
. 2025-01-16 12:10:22.079 ..;d;0;2025-01-08T21:06:53.000Z;4;"root" [0];"1001" [1001];rwxr-xr-x;0
. 2025-01-16 12:10:22.079 School_checks2.xlsx;-;1327748;2025-01-15T18:50:08.000Z;4;"1006" [1006];"1001" [1001];rw-r--r--;0
. 2025-01-16 12:10:22.844 Increasing send buffer from 524288 to 1048576
. 2025-01-16 12:10:25.254 Closing connection.
. 2025-01-16 12:10:25.254 Sending special code: 1
. 2025-01-16 12:10:25.285 Session sent command exit status 0
. 2025-01-16 12:10:25.285 Main session channel closed
. 2025-01-16 12:10:25.285 All channels closed
I don't know why it works with the GUI but not the script. I tried adding RawSite Settings of:
-rawsettings HostKey="ed25519,ed448,rsa,ecdsa,dsa,WARN" to the open command but I still received the same error
Couldn't agree a host key algorithm (available: rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519)
So, two questions. Why does the script log file show an old version of WinSCP and how do I overcome this error message?
Last edited by AmyMorgan9 on 2025-01-16 19:46; edited 1 time in total

Reply with quote

Advertisement

AmyMorgan9
Joined:
Posts:
2
Location:
Naples, Florida

I figured out the issue

I didn't realize that the WinSCP executable was in the directory of my batch job and that was the version that was being run. Once I copied over the new application to the batch folder directory, the application error went away.

I did see that another user had the same error message and the solution was to upgrade WinSCP but I was running the newest version so I did not think this applied to me.

Reply with quote

Advertisement

You can post new topics in this forum