Prerequisites
Steps to reproduce
Environment
- Windows Server 2025
- OpenSSH_for_Windows_9.5p2
- Windows PowerShell 5.1
- Remote server: Debian 13 (OpenSSH_10.0p2)
- ED25519 public key authentication
The scheduled task executes:
powershell.exe -ExecutionPolicy Bypass -File D:\archive\bin\archive_job.ps1
The PowerShell script runs:
Write-Host "Create remote directory..."
ssh `
-i $TransferKey `
"$TransferUser@$TransferHost" `
"mkdir -p '$RemoteDir'"
The message Create remote directory... is printed immediately before ssh.exe is started.
Reproduction result
The issue occurs only when the scheduled task is started through:
- Start-ScheduledTask
- schtasks /Run
The following execution methods work correctly:
- Running archive_job.ps1 directly from PowerShell
- Clicking "Run" from the Task Scheduler GUI
When the issue occurs, PowerShell prints:
Create remote directory...
and never returns from the ssh command.
No further output is produced.
Expected behavior
ssh.exe should complete normally regardless of how the scheduled task is started.
Starting a task through Task Scheduler API should behave the same as running the task from the Task Scheduler GUI or executing the PowerShell script directly.
Actual behavior
When the scheduled task is started through Start-ScheduledTask or schtasks /Run, ssh.exe hangs.
The script prints "Create remote directory..." immediately before starting ssh.exe, then PowerShell never returns from the ssh command.
The remote command is not completed from the client's point of view.
Error details
No PowerShell exception is generated.
PowerShell simply waits indefinitely for ssh.exe to exit.
Environment data
Name Value
---- -----
PSVersion 5.1.26100.32370
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.26100.32370
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Version
OpenSSH_for_Windows_9.5p2, LibreSSL 3.8.2
Visuals
Additional observations:
Adding either of the following options completely avoids the issue:
ssh -E D:\archive\ssh_debug.log ...
All three complete successfully.
The issue only occurs with a normal ssh invocation without debugging options.
When using -vvv, the SSH debug log shows:
- Authentication succeeds.
- The remote command is sent successfully.
- Exit status is 0.
- The SSH session closes normally.
The Debian OpenSSH server also reports a successful authentication and command execution.
Therefore, this appears to be a client-side issue triggered only when ssh.exe is started through the Task Scheduler API.
Prerequisites
Steps to reproduce
Environment
The scheduled task executes:
The PowerShell script runs:
The message
Create remote directory...is printed immediately beforessh.exeis started.Reproduction result
The issue occurs only when the scheduled task is started through:
The following execution methods work correctly:
When the issue occurs, PowerShell prints:
and never returns from the ssh command.
No further output is produced.
Expected behavior
Actual behavior
Error details
Environment data
Version
OpenSSH_for_Windows_9.5p2, LibreSSL 3.8.2
Visuals
Additional observations:
Adding either of the following options completely avoids the issue:
ssh -v ...ssh -vvv ...ssh -E D:\archive\ssh_debug.log ...All three complete successfully.
The issue only occurs with a normal ssh invocation without debugging options.
When using
-vvv, the SSH debug log shows:The Debian OpenSSH server also reports a successful authentication and command execution.
Therefore, this appears to be a client-side issue triggered only when ssh.exe is started through the Task Scheduler API.