UPDATE: Just to confirm more about my setup in case it wasn't clear:
No private keys are ever shared anywhere.
(1) Human programmers using Mac each have one SSH key (in ~/.ssh/id_rsa) that they use to connect to all my BitBucket repositories (one company account). The public key element is placed in BitBucket to authorise them and that approves that one human for all of my BitBucket repositories.
(2) Ubuntu servers each have their own key pair setup and have one SSH key for each BitBucket repository they are approved to. Each public key is placed in each of the corresponding BitBucket repositories.
Basically I am trying to have one composer.json file (that uses the URL format shown below) work for both humans and servers (i.e. to work when a human has one SSH key to access all my BitBucket repositories (same account) -AND- when a server has individual SSH keys to access each BitBucket repository they are approved for).
I need to be able to configure my ~/.ssh/config file to use all these URLS:
email@example.com:username/repository-abc.git firstname.lastname@example.org:username/repository-12345.git email@example.com:username/another-repo.git
...but I can't use an alias.
So I CAN'T do this:
git@alias1:username/repository-abc.git git@alias2:username/repository-12345.git git@alias3:username/another-repo.git
The reason is that the URLs are to go in a composer.json file that is also used by local development computers that just use one SSH key for all the BitBucket repositories - and aren't configured to understand all the different aliases.
I can configure the server how I want it though and I have the below ~/.ssh/config configuration on the server.
Whenever it tries to read a private key file that isn't valid (e.g. the 2nd/3rd repo will try to read the first one first) it will fail. However, this can sort of work if I selectively enter the SSH key passphrase when it is the correct one, but ignore (just pressing enter) when it is not the correct one.
Host bitbucket.org HostName bitbucket.org IdentityFile ~/.ssh/alias1_private_key Host bitbucket.org HostName bitbucket.org IdentityFile ~/.ssh/alias2_private_key Host bitbucket.org HostName bitbucket.org IdentityFile ~/.ssh/alias3_private_key
It would be easy to just configure the aliases, but because the dev computers wouldn't understand that then I am stuck.
Is there a way to do something this below so that it can work for everything?
Host bitbucket.org HostName bitbucket.org Url firstname.lastname@example.org:username/repository-abc.git IdentityFile ~/.ssh/alias1_private_key Host bitbucket.org HostName bitbucket.org Url email@example.com:username/repository-12345.git IdentityFile ~/.ssh/alias2_private_key