Skip to content

Instantly share code, notes, and snippets.

@zaunere
Last active February 15, 2025 21:29
Show Gist options
  • Save zaunere/4447268c56ea410b7bb8e628a28dfef2 to your computer and use it in GitHub Desktop.
Save zaunere/4447268c56ea410b7bb8e628a28dfef2 to your computer and use it in GitHub Desktop.

This seems to work for using a private key when sharing a .ssh\config between MacOS and Windows.

In the config:

# Windows-specific configuration
Match exec "cmd /c if defined OS (exit 0) else (exit 1)"
    IdentityFile C:/Users/myuser/OneDrive/Documents/.ssh/id_ed25519

# macOS/Linux-specific configuration
Match exec "cmd /c if defined OS (exit 1) else (exit 0)"
    IdentityFile ~/.ssh/id_ed25519

Then don't include an IdentityFile for the host entries.

   Host the.host.com
     HostName  the.host.com
     Port 22
     User theuser
##     IdentityFile "~\.ssh\id_ed25519"

Using expansion on Windows didn't work out.

Thanks to GPT for this one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment