Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-PSSession error "subsystem request failed on channel 0" when using SSH key authentication #5945

Closed
pcgeek86 opened this issue Jan 19, 2018 · 4 comments
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a Resolution-Answered The question is answered.

Comments

@pcgeek86
Copy link

Reproduction Steps

New-PSSession -SSHTransport -UserName SpockAdmin -KeyFilePath /Users/tsulli/Spocks_Private_Key.pem -HostName x.x.x.x

Symptom

New-PSSession : [x.x.x.x] The background process reported an error with the following message: The SSH client session has ended with error message: subsystem request failed on channel 0.

NOTE: I'm able to successfully SSH into the system using the ssh command line client from Mac.

Fix

Make sure your sshd_config contains the Subsystem configuration as documented in the following article:
https://docs.microsoft.com/en-us/powershell/scripting/core-powershell/ssh-remoting-in-powershell-core

After modifying the sshd_config, you also need to restart the SSH daemon on your Windows instance: Restart-Service -Name sshd.

Closing immediately, as I found the fix. This is being posted purely for community documentation purposes, so others can benefit from my learnings.

@iSazonov iSazonov added Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a Resolution-Answered The question is answered. labels Jan 19, 2018
@RangaSamudrala
Copy link

sshd_config is located in %ProgramData%\ssh AND NOT where OpenSSH is installed.

@sunzcosmo
Copy link

sunzcosmo commented Nov 20, 2018

The problem keeps existing after I add the Subsystem, run 'sshd -T' shows that my config has already been loaded:

PS> sshd -T | select-string 'subsystem'

subsystem sftp sftp-server.exe
subsystem powershell c:\pwsh\pwsh.exe -sshs -NoLogo -NoProfile

The ssh cmd still can not figuring out the name 'powershell':

PS> ssh root@10.90.183.191 -s powershell
Authorized users only. All activity may be monitored and reported.
Password:
subsystem request failed on channel 0

operation system:

PS>((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion\" -Name ProductName).ProductName)
Windows 7 Professional

My openssh version is

PS>((Get-Item (Get-Command sshd).Source).VersionInfo.FileVersion)
7.7.2.0

Powershell Version

PS> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0
PSEdition                      Core
GitCommitId                    6.1.0
OS                             Microsoft Windows 6.1.7601 S
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

@ulibte
Copy link

ulibte commented Oct 17, 2020

Subsystem powershell pwsh.exe -sshs -NoLogo -NoProfile

@cawoodm
Copy link

cawoodm commented Sep 30, 2021

Borken Link:

https://docs.microsoft.com/en-us/powershell/scripting/learn/remoting/ssh-remoting-in-powershell-core?view=powershell-7.1

Explains how to set up the SSH protocol for PowerShell remoting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a Resolution-Answered The question is answered.
Projects
None yet
Development

No branches or pull requests

6 participants