PowerShell / Win32-OpenSSH

Win32 port of OpenSSH
7.32k stars 753 forks source link

"SSH-2.0-OpenSSH_for_Windows_9.5' is not recognized as an internal or external command, operable program or batch file. #2252

Open phr34k opened 1 month ago

phr34k commented 1 month ago

Prerequisites

Steps to reproduce

I updated openssh installations on a machine running sshd through winget because they were quite dated. Unfortunately, I could only find the beta releases. When connecting to the machine it gives out the following error "'SSH-2.0-OpenSSH_for_Windows_9.5' is not recognized as an internal or external command, operable program or batch file."

To work around the issue on the server, I've just copied over the sshd executable and renamed it 'SSH-2.0-OpenSSH_for_Windows_9.5'. This supringsinly works well, but when connecting from other clients like the one bundled with git setup it'll complain about other variants of executables missing e.g. "'SSH-2.0-OpenSSH_9.7' is not recognized as an internal or external command, operable program or batch file."

On surface, it seems that when connecting to sshd, the ssh version the user uses relays some information about client version used and the sshd(eamon) uses that to fork the process.

Expected behavior

ssh connects without disconnecting due to missing executable based on client versiion

Actual behavior

> ssh server@ipv6address

debug1: channel 0: new session [client-session] (inactive timeout: 0)
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: filesystem
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: client_input_hostkeys: searching C:\\Users\\phpfr/.ssh/known_hosts for [127.0.0.1]:2222 / (none)
debug1: client_input_hostkeys: searching C:\\Users\\phpfr/.ssh/known_hosts2 for [127.0.0.1]:2222 / (none)
debug1: client_input_hostkeys: hostkeys file C:\\Users\\phpfr/.ssh/known_hosts2 does not exist
debug1: client_input_hostkeys: host key found matching a different name/address, skipping UserKnownHostsFile update
debug1: pledge: fork
'SSH-2.0-OpenSSH_for_Windows_9.5' is not recognized as an internal or external command,
operable program or batch file.
debug1: channel 0: free: client-session, nchannels 1
Connection to 127.0.0.1 closed by remote host.
Transferred: sent 3236, received 3260 bytes, in 34.3 seconds
Bytes per second: sent 94.2, received 94.9
debug1: Exit status -1

PS > ssh server@ipv6address

debug1: channel 0: new session [client-session] (inactive timeout: 0)
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: filesystem
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: client_input_hostkeys: searching C:\\Users\\phpfr/.ssh/known_hosts for [127.0.0.1]:2222 / (none)
debug1: client_input_hostkeys: searching C:\\Users\\phpfr/.ssh/known_hosts2 for [127.0.0.1]:2222 / (none)
debug1: client_input_hostkeys: hostkeys file C:\\Users\\phpfr/.ssh/known_hosts2 does not exist
debug1: client_input_hostkeys: host key found matching a different name/address, skipping UserKnownHostsFile update
debug1: pledge: fork
'SSH-2.0-OpenSSH_9.7' is not recognized as an internal or external command,
operable program or batch file.
debug1: channel 0: free: client-session, nchannels 1
Connection to 127.0.0.1 closed by remote host.
Transferred: sent 3236, received 3260 bytes, in 34.3 seconds
Bytes per second: sent 94.2, received 94.9
debug1: Exit status -1

Error details

n/a

Environment data

n/a

Version

This problem seems to happen for both ssh bundled in git, and the one installed from this repository.

SSH-2.0-OpenSSH_for_Windows_9.5 <--> SSH-2.0-OpenSSH_for_Windows_9.5 SSH-2.0-OpenSSH_9.7 <--> SSH-2.0-OpenSSH_for_Windows_9.5

Visuals

n/a

phr34k commented 1 month ago

A temporary workaround is copying the sshd executable ( server ) and naming it "SSH-2.0-OpenSSH_for_Windows_9.5", this particulair error then gets resolved, however it's impossible sshd copies for every client out there, so the underlying issue should still be fixed imho.

tgauth commented 1 month ago

Are you still facing this issue? Can provide the full debug logs from both the ssh client and server? https://github.com/PowerShell/Win32-OpenSSH/wiki/Troubleshooting-Steps has info on collecting the logs.

phr34k commented 1 month ago

@tgauth to my knowledge I am still having this error. As stated I did find a workaround, that holds up for now, but if I remove those copies of the executable the error comes back. I don't have any server logs at the moment.