You’re on the right track by editing the sshd_config file, but connecting directly to PowerShell as your default shell via OpenSSH in Windows requires a couple of careful steps and some gotchas specific to Windows’ handling of shells and users.
Here’s how you can ensure that ssh logins from your Fedora workstation use PowerShell as the default shell instead of cmd.exe:
1. Ensure PowerShell Subsystem is Correct
Your line is nearly perfect, but let’s confirm the path and syntax. On a default Windows install, the 64-bit PowerShell 7.x usually resides in:
C:\Program Files\PowerShell\7\pwsh.exe
So your sshd_config should have:
Subsystem powershell C:/Program Files/PowerShell/7/pwsh.exe -sshs
or, using short names (which should also work, as you had):
Subsystem powershell C:/PROGR~1/POWERS~1/7/pwsh.exe -sshs
Make sure there are no typos or extra spaces.
2. Specify the Subsystem When Connecting
By default, ssh will launch the Windows shell defined in your profile (cmd.exe unless changed). To explicitly get PowerShell, from your Linux machine, you should connect like this:
ssh -s powershell username@windows_hostname_or_ip
The
-s powershell
part tells ssh to use the “powershell” subsystem, which you defined above.
3. Setting PowerShell as the Default Shell (Optional)
If you want every user who connects to always get PowerShell (without specifying a subsystem), you can change the user’s default shell in the Windows registry, but this is generally NOT recommended unless you know exactly what you’re changing, because it can impact regular console/logon sessions.
Instead, create a file at:
C:\Users\<yourusername>\.ssh\rc
Put this line in it:
pwsh.exe -sshs
This will run PowerShell on login for your user.
Or, use a Group Policy/local security policy to set the default shell. For advanced (multi-user) systems, see documentation on forced command or setting the shell per-user in the sshd_config.
4. Check sshd Logs
If you’re still getting cmd, check the Windows Event Viewer for sshd logs, or look at the logs in:
C:\ProgramData\ssh\logs
This might reveal a permission issue or a misconfiguration.
Recap Example:
- Add to
C:\ProgramData\ssh\sshd_config
:
Subsystem powershell C:/Program Files/PowerShell/7/pwsh.exe -sshs
- Restart the OpenSSH server (
services.msc
→ OpenSSH SSH Server → Restart).
- From Linux, connect with:
ssh -s powershell youruser@yourwindowsip
If you do these steps and still get cmd.exe, please let me know any error messages or logs (or describe exactly what you see after connecting), and we’ll dig deeper!
Let me know how it goes or if you need more step-by-step help.