Skip to content

Support OpenSSH -F / config file selection for SSH remoting #27409

@shd013

Description

@shd013

Summary of the new feature / enhancement

PowerShell SSH remoting supports passing OpenSSH -o options through -Options, but there does not seem to be a supported way to pass OpenSSH -F.

This means there is no clean equivalent of:

ssh -F none server01
ssh -F C:\Temp\isolated_ssh_config server01

for SSH-based PowerShell remoting:

New-PSSession -HostName server01
Enter-PSSession -HostName server01
Invoke-Command -HostName server01 -ScriptBlock { hostname }

In some environments, SSH client configuration is centrally managed on shared systems. This may include routing rules, jump hosts, proxy settings, identity files, or other defaults that are useful for normal interactive SSH usage.

However, automation and troubleshooting sometimes need to bypass inherited SSH client configuration and connect with a clean or isolated SSH configuration.

This is especially relevant when the user running PowerShell does not have permission to edit or temporarily disable the central SSH client config, for example C:\ProgramData\ssh\ssh_config on Windows. In those cases, it can be difficult to verify whether a PowerShell SSH remoting issue is caused by the target host, PowerShell remoting itself, or inherited SSH client config.

With plain OpenSSH this can be done with:

ssh -F none server01

With PowerShell SSH remoting, -Options can pass ssh -o key=value options, but -F is not an ssh_config directive and cannot be represented correctly that way.

The expected benefit is that PowerShell SSH remoting would behave more consistently with direct ssh.exe usage and be easier to troubleshoot in environments where inherited SSH client config may affect connection behavior.

Proposed technical implementation details (optional)

Add a parameter for SSH-based remoting, for example:

New-PSSession  -HostName server01 -SSHConfigFile none
Enter-PSSession -HostName server01 -SSHConfigFile none
Invoke-Command -HostName server01 -SSHConfigFile none -ScriptBlock { hostname }

And:

New-PSSession -HostName server01 -SSHConfigFile C:\Temp\isolated_ssh_config

This should map to the underlying OpenSSH client as:

-F none

or:

-F C:\Temp\isolated_ssh_config

-Options maps naturally to ssh -o key=value.

OpenSSH -F is a command-line option, not an ssh_config option.

Therefore this cannot be expressed correctly as:

-Options @{ ... }

The parameter should apply to the SSH-based remoting parameter sets used by New-PSSession, Enter-PSSession, and Invoke-Command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions