Search code examples
gitsshcomposer-phpddev

Managing multiple GitHub Accounts (ssh keys) for Composer require in DDEV under WSL2


i have added a second 2 ssh keys and added the needed config in ubuntu WSL2 ~/.ssh

      Host github-key2
        HostName github.com
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/key2

so in UBUNTU this works:

    git clone git@github-key2:vendor/repoxxx.git 

But i need to geht this running in ddev with composer:

I added git@github-key2:vendor/repoxxx.git in the repositories section of composer in same Way i did it for other protected repos

    "vendor/repoxxx": {
        "type": "vcs",
        "url": "git@github-key2:vendor/repoxxx"
    }

ddev auth ssh (both keys where added)

but composer in DDEV just uses the normal "id_rsa" key but not the second "key2"

    ddev composer req vendor/repoxxx

Solution

  • You'll need to put a .ssh/config file into the container. The normal way to do this is to put the .ssh/config that you need into homeadditions, either in the project or global homeadditions.

    Docs on homeadditions are at https://ddev.readthedocs.io/en/latest/users/extend/in-container-configuration/

    For some people, just symlinking or copying their host-side .ssh/config works, but for most situations you'll need a custom .ssh/config for use inside the container.