PowerShell / PowerShell/Win32-OpenSSH

OpenSSH Server does not know how to handle Application Execution Aliases (AppExecLinks)

Open
#1,862 1 comment 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
8.3k
Forks
819
PR merge metrics
No merged PRs in 30d

Description

Troubleshooting steps
https://github.com/PowerShell/Win32-OpenSSH/wiki/Troubleshooting-Steps

Terminal issue? please go through wiki
https://github.com/PowerShell/Win32-OpenSSH/wiki/TTY-PTY-support-in-Windows-OpenSSH

Please answer the following

"OpenSSH for Windows" version
((Get-Item (Get-Command sshd).Source).VersionInfo.FileVersion)

Local Windows machine: 8.1.0.1
Remote Windows machine: 8.1.0.1

Server OperatingSystem
((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion\" -Name ProductName).ProductName)

Windows 10 Enterprise
Note: I can also repro this with the remote machine having Windows 11 installed.

Client OperatingSystem

Windows 10 Enterprise <- This is the output of the above command but my local machine has Windows 11.

What is failing

If PowerShell 7 is installed in that remote machine via either Microsoft Store or winget, then it cannot be used for ssh connections because OpenSSH Server is unable to handle Application Execution Aliases (AppExecLinks) properly.

Repro steps:

  1. In the remote Windows machine, install OpenSSH Server via Settings -> Apps -> Optional Features.
  2. In the remote machine, install PowerShell 7 via Microsoft Store, or via winget. Installing it this way will place the executable in %LOCALAPPDATA%\Microsoft\WindowsApps\Microsoft.PowerShell_8wekyb3d8bbwe\pwsh.exe. Windows will then automatically create an Application Execution Alias in the parent folder: %LOCALAPPDATA%\Microsoft\WindowsApps\pwsh.exe.
  3. In the remote machine, open Registry Editor, navigate to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH, and set the value DefaultShell to either one of the two pwsh.exe links mentioned in the previous step. Note: If the regkey value does not exist, create it as a string.
  4. From your local machine, open any terminal (cmd, PowerShell, even bash if you're on Linux), and connect via ssh to the remote machine.

Expected output

The connection succeeds, and a PowerShell prompt shows up.

Actual output

The ssh connection fails.

Workaround: In the remote machine, uninstall PowerShell that was installed via Microsoft Store or winget, and instead download the MSI installer from here: https://github.com/PowerShell/PowerShell . Then change the DefaultShell value to point to the C:\Program Files\PowerShell\7\pwsh.exe executable.

This issue was originally opened in the VSCode repo because some of us thought the problem was with VSCode itself, but it's not.
The steps I provided in that issue are slightly different: VSCode is capable of deciding which shell to invoke from the remote machine, so step 3 from the above instructions differ a bit.
https://github.com/microsoft/vscode/issues/115581#issuecomment-909671483

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with the HKLM\SOFTWARE\OpenSSH DefaultShell value set to the Microsoft.PowerShell AppExecLink at %LOCALAPPDATA%\Microsoft\WindowsApps\pwsh.exe. Compare this with the working C:\Program Files\PowerShell\7\pwsh.exe path and investigate how the OpenSSH server launches DefaultShell. Done means an SSH connection reaches a PowerShell prompt for the AppExecLink configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.