Repository navigation
Closed
Labels
Issue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreWG-RemotingPSRP issues with any transport layer
Description
Using a Banner option within sshd_config causes the connection to fail
Banner /etc/ssh/banner
If we comment out the Banner line, and restart sshd, client connections work just fine.
Steps to reproduce
PS /Users/drewstinnett> Enter-PSSession -Host host.example.com -SSHTransport -UserName drews
Enter-PSSession : The background process reported an error with the following message: The SSH client session has ended with error message:
####
# Example Banner
####
At line:1 char:1
+ Enter-PSSession -Host host.example.com -SSHTransport -UserNam ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStructureException,Microsoft.PowerShell.Commands.EnterPSSessionCommand
PS /Users/drewstinnett>
Expected behavior
PS /Users/drewstinnett> Enter-PSSession -Host host.example.com -SSHTransport -UserName drews
####
# Example Banner
####
[host.example.com]: PS /home/drews>Actual behavior
PS /Users/drewstinnett> Enter-PSSession -Host host.example.com -SSHTransport -UserName drews
Enter-PSSession : The background process reported an error with the following message: The SSH client session has ended with error message:
####
# Example Banner
####
At line:1 char:1
+ Enter-PSSession -Host host.example.com -SSHTransport -UserNam ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [Enter-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : System.Management.Automation.Remoting.PSRemotingDataStructureException,Microsoft.PowerShell.Commands.EnterPSSessionCommand
PS /Users/drewstinnett>Environment data
PowerShell v6.0.0-beta.8
Copyright (C) Microsoft Corporation. All rights reserved.
PS /root> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.0-beta.8
PSEdition Core
GitCommitId v6.0.0-beta.8
OS Linux 3.10.0-693.2.2.el7.x86_64 #1 SMP Sat Sep 9 03:55:24 EDT 2017
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
PS /root>Metadata
Metadata
Assignees
Labels
Issue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreWG-RemotingPSRP issues with any transport layer
Activity
PaulHigin commentedon Oct 20, 2017
PowerShell currently uses stderror messages to determine if ssh client fails during remoting initial connection, such as an authorization failure or some configuration caused failure, and then reports the failure message to the user. But this is turning out to be unreliable since ssh passes warnings and (now) banner text stderror too.
The banner text comes through stderror and PowerShell cannot distinguish it from a real ssh error, so it closes the session. PowerShell currently looks for "WARNING:" prepended to a stderror message and ignores those. But I don't see a way to ignore a random string appearing in stderror.
This is only for the initial connection and the protocol handles connection errors after that. I think we will need to add some kind of connection integrity check before starting the protocol to ensure the initial connection succeeded. It will involve ensuring the ssh client process is alive since it will terminate on error.
In the mean time the workaround is to not turn on the banner message for sshd configuration.
JacobStruiksma commentedon May 18, 2020
Is this issue going to be investigated?If a banner is used (for example in corporate environments with a legal statement before connecting to a linux machine) , you need a windows machine for powershell remoting to other linux machines.
JacobStruiksma commentedon Jan 16, 2021
It still does not work as expected.
The clients as the destination is installed with Powershell 7.1.1
The destination linux machine is properly configured with an banner for sshd.
On the client windows machine, i don't see the banner. On the client linux machine i got an error.
On a windows machine I got the following:
On a linux machine I got the following:
JacobStruiksma commentedon Aug 18, 2021
Still not working for Powershell 7.1.4 or 7.2.0-preview.8.
Enable-ExperimentalFeature PSNotApplyErrorActionToStderrdoes not seem to help. Using-ErrorAction continueonNew-PSSessiondoes also not change the resultthukk commentedon Oct 6, 2021
Any update on progress with this bug? This issue also happens when attempting to created a connection from Linux to Linux. I can bypass the SSH prompt by setting no banner in sssh_config, but if FIPs Mode is enabled, the connection errors out as SSH says "The background process reported an error with the following message: The SSH client session has ended with error message: FIPS mode initialized."
Even if it writes to
stderr, that is fine - but at least make it respect the ErrorAction setting (it currently Stops, regardless of the set Error Action). That would be bare minimum.thukk commentedon Nov 10, 2022
Can confirm - this works with PowerShell 7.3. Suggest closing the issue.
JacobStruiksma commentedon Nov 24, 2022
Works for me too. issue has been resolved.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.