PowerShell / Win32-OpenSSH

Win32 port of OpenSSH
7.36k stars 757 forks source link

Is ~/.ssh/config supported? #2192

Closed cmonty14 closed 8 months ago

cmonty14 commented 8 months ago

Prerequisites

Steps to reproduce

After creating SSH keypair for public key authentication successfully I wonder if I can user a SSH configuration file ~/.ssh/config? Please note that I'm not talking about SSH Server configuration file _sshdconf.

This SSH configuration file could have this content:

Host remote-server
    HostName remote-server
    User d038783
    IdentityFile C:\Users\Name\.ssh\id_ed25519
    IdentitiesOnly yes
    ForwardAgent no
    PreferredAuthentications publickey
    ControlPath C:\Users\Name\.ssh\cm-%r@%h:%p
    ControlMaster auto
    ControlPersist 10m

If SSH configuration file ~/.ssh/config is supported, are there any restrictions regarding SSH options? And what is the correct syntax when using a path? / or \?

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.22631
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_8.6p1, LibreSSL 3.4.3

matsmcp commented 8 months ago

c:\users\username.ssh\config is supported. you can add Host aliases in it. I don't know if all values/options are supported.

cmonty14 commented 8 months ago

This issue is solved.

I created file C:\user\username.ssh\config with this content:

Host *
    ServerAliveInterval 180
    ServerAliveCountMax 3
    ForwardAgent no
    RemoteForward /run/user/2038783/gnupg/S.gpg-agent ~/AppData/Local/gnupg/d.o35wa9tdt49rzsbu/S.gpg-agent.extra

You'll notice the forward-slash / in line RemoteForward that works for the path ~/AppData/Local/gnupg/d.o35wa9tdt49rzsbu/S.gpg-agent.extra on Windows client.