Unable to use scp or sftp when using PowerShell as the subsystem unless the profile is basically blank
@tgauth is already working on this.
Since Mar 16, 2026.
Assessment
This issue has not been assessed yet.
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest version
- Search the existing issues.
Steps to reproduce
I am working on configuring an enterprise to have Windows OpenSSH installed on all systems that support the feature.
At that time I am also ensuring that PowerShell v7 is installed and that the SSH subsystem is pwsh.
I have that all working. What I have an issue with is if there is a PowerShell profile of any significance neither scp or sftp will work.
I have spent significant time "talking" with AI about this and it says (and I have basically proved it out) that the PowerShell profile needs to be "clean"
"When sftp or scp connects, it starts a session to initialize the subsystem. If your PowerShell profile contains commands that produce visual output (like a custom prompt, a "Welcome" banner, or a tool update check), that text is sent over the data stream. The SFTP client expects a specific binary protocol header; when it receives "Welcome to PowerShell" instead, it chokes and terminates the connection."
Subsystem powershell C:\PROGRA~1\POWERS~1\7\pwsh.exe -SSHS -NoProfile -NoLogo
Subsystem sftp C:\Windows\System32\OpenSSH\sftp-server.exe
So I either have to:
- Use CMD.EXE as the shell ... that IS NOT going to happen
- Use a totally neutered, or ZERO PowerShell profile - That is not going to happen either. I want all users to have a prompt that has the time, the domain, the user, the computer name, and the directory that they are in
- Or, jump through hoops to get scp and sftp to work and have a real profile
Expected behavior
scp and sftp work when the shell is PowerShell and you have an actual profile
Preference #1 - fix it and make it just work ... always ... like *nix
Preference #2 - document that it doesn't work, why it doesn't work, and example(s) on how to fix it
Actual behavior
connection closed
Error details
Environment data
This is from the most recent machine that I was doing this on but I have happened on Server 2019 and Server 2022 also
Name Value
---- -----
PSVersion 7.5.4
PSEdition Core
GitCommitId 7.5.4
OS Microsoft Windows 10.0.26200
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Version
OpenSSH_for_Windows_9.5p2, LibreSSL 3.8.2
Visuals
No response
- Dominant language
- No language data
- Stars
- 8.3k
- Forks
- 820
- Avg merge
- 12m
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PowerShell/Win32-OpenSSH
-
Area-ssh-agent Issue-Upstream Parity
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
PowerShell/Win32-OpenSSH#2458 · 1 reaction ·
-
Area-Authentication Area-Logging/Diagnostics Area-sshd Investigate Issue-Bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
PowerShell/Win32-OpenSSH#2466 · 1 comment · 1 reaction ·
-
Area-sshd Area-Terminal Investigate Issue-Regression
Difficulty 4/5 3-5 days Newbie friendliness 48/100
PowerShell/Win32-OpenSSH#2465 · 1 comment · 1 reaction ·
-
Area-ssh-agent Issue-Enhancement
Difficulty 5/5 Over a week Newbie friendliness 25/100
PowerShell/Win32-OpenSSH#2462 · 1 comment · 1 reaction ·
-
Area-ssh-agent Investigate
Difficulty 5/5 Over a week Newbie friendliness 25/100
PowerShell/Win32-OpenSSH#2460 · 1 reaction ·