Skip to content

Unable to connect to SSH server with proxycommand #2412

@hidoolou007

Description

@hidoolou007

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

Hi,
I have a Windows 2025 Server with OpenSSH enabled.
I need to connect to this server through a SSH bastion.

I have activated PowerShell as the default shell for OpenSSH following the MS guide.

I have no problem to connect to my server with the following full command:

ssh -t -l [email protected]:bastionuser bastion.domain.local

Which gives me the following output:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\remoteuser>

My problem is that I want to automate some tasks on many targets so I need to configure my ~/.ssh/config file in order to make the previous command line reusable.

Here is my config file:

Host bastion
   User bastionuser
   Hostname bastion.domain.local
   Port 22
   StrictHostKeyChecking no
   IdentityFile ~/.ssh/id_rsa

Host target
    Hostname target.domain.local
    User remoteuser
    ProxyCommand ssh -T -l remoteuser@%h:bastionuser bastion

So when I do ssh target -vvv I got the following error:

[...]
debug1: kex_exchange_identification: banner line 11: Windows PowerShell
debug1: kex_exchange_identification: banner line 12: Copyright (C) Microsoft Corporation. All rights reserved.
debug1: kex_exchange_identification: banner line 13:
debug1: kex_exchange_identification: banner line 14: Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
debug1: kex_exchange_identification: banner line 15:
debug1: kex_exchange_identification: banner line 16: PS C:\\Users\\remoteuser> SSH-2.0-OpenSSH_9.9
SSH-2.0-OpenSSH_9.9 : The term 'SSH-2.0-OpenSSH_9.9' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:1
+ SSH-2.0-OpenSSH_9.9
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (SSH-2.0-OpenSSH_9.9:String) [], CommandNotFoundExc
   eption
    + FullyQualifiedErrorId : CommandNotFoundException

It seems like the server tries to execute the SSH client version as an executable after being successfully connected.

I tried to disable the Banner option (which is already disabled by default). Renamed ssh.exe (on the server side) in SSH-2.0-OpenSSH_9.9.exe and the problem still occurs. Instead of the error message, it gives me the following output:

usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address]
           [-c cipher_spec] [-D [bind_address:]port] [-E log_file]
           [-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file]
           [-J destination] [-L address] [-l login_name] [-m mac_spec]
           [-O ctl_cmd] [-o option] [-P tag] [-p port] [-Q query_option]
           [-R address] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
           destination [command [argument ...]]

Which is the behaviour the server wants to do (execute a command after login). But It never gives me the prompt back and I'm unable to do anything with that.

It seems to be a limitation of OpenSSH on Windows server and I'm stuck for a week now to find a fix.

Any idea?

Thanks

Expected behavior

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\remoteuser>

Actual behavior

debug1: kex_exchange_identification: banner line 11: Windows PowerShell
debug1: kex_exchange_identification: banner line 12: Copyright (C) Microsoft Corporation. All rights reserved.
debug1: kex_exchange_identification: banner line 13:
debug1: kex_exchange_identification: banner line 14: Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
debug1: kex_exchange_identification: banner line 15:
debug1: kex_exchange_identification: banner line 16: PS C:\\Users\\remoteuser> SSH-2.0-OpenSSH_9.9
SSH-2.0-OpenSSH_9.9 : The term 'SSH-2.0-OpenSSH_9.9' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:1
+ SSH-2.0-OpenSSH_9.9
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (SSH-2.0-OpenSSH_9.9:String) [], CommandNotFoundExc
   eption
    + FullyQualifiedErrorId : CommandNotFoundException

Error details

Environment data

Name                           Value
----                           -----
PSVersion                      5.1.26100.4652
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.26100.4652
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Version

SSH-2.0-OpenSSH_for_Windows_9.5

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions