question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Powershell Subsystem Fails when using a banner in OpenSSH

See original GitHub issue

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>

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
JacobStruiksmacommented, 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.

0reactions
JacobStruiksmacommented, Nov 24, 2022

Works for me too. issue has been resolved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passwordless SSH login into WSL2 failing
First, the most likely reason for it failing is as Ramhound ... Confirm that you can log to Windows OpenSSH from WSL using...
Read more >
Powershell remote fails with "The SSH client session has ...
The SSH client session has ended with error message: subsystem request failed on channel 0.
Read more >
What causes SSH error: kex_exchange_identification ...
I get the error: kex_exchange_identification : Connection closed by remote ... You can specify a custom port using ssh -p port user@host.
Read more >
PowerShell remoting to Linux Servers
Scroll down and change “Banner /etc/motd” to “#Banner /etc/motd“, use CTRL-X, Y, and Enter to Save the file and Quit. Run “sudo service...
Read more >
about Pwsh - PowerShell
Explains how to use the `pwsh` command-line interface. Displays the command-line parameters and describes the syntax.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found