Thursday, 24 September 2026

Multi-account Repos - errors

Set up 
C:\Users\<username>\.ssh\config

Host github-account1

    HostName github.com

    User git

    IdentityFile ~/.ssh/<folder1>/id_ed25519


Host github-account2

    HostName github.com

    User git

    IdentityFile ~/.ssh/<folder2>/id_ed25519



I had a problem where 
  • ssh -T git@github-account1 working
  • git ls-remote account1 failing

  • The reason was that the commands were using different SSH executables:

    Manual SSH:
    C:\Windows\System32\OpenSSH\ssh.exe
     
    Git:
    C:\Program Files\Git\mingw64\bin\ssh.exe

    Your Windows OpenSSH was correctly reading:
    C:\Users\AndrewPotts\.ssh\config

    and using the github-account2 host alias, while Git's bundled SSH was not behaving the same way.

    Fixed with:
    git config --global core.sshCommand "C:/Windows/System32/OpenSSH/ssh.exe"

    If you use  ssh-agent  (OpenSSH Authentication Agent)
    and add the private keys, it should persist across reboots

    ssh-add C:\Users\<username>\.ssh\<account1>\id_ed25519

    ssh-add C:\Users\<username>\.ssh\<account2>\id_ed25519