The %r and %h in the IdentityFile (~/.ssh/%r@%h_id_rsa) will always be the same as the remote user and remote host used to authenticate.
In the example i've changed Hostname
Host github.com bitbucket.org bitbucket.com
IdentityFile ~/.ssh/%r@%h_id_rsa
Hostname newhostname.com
Test
$ ssh -Tv [email protected]
Result
debug1: Authenticating to github.com:22 as 'tarranjones'
debug1: Offering RSA public key: ~/.ssh/[email protected]_id_rsa
In this example i've changed User
Host github.com bitbucket.org bitbucket.com
IdentityFile ~/.ssh/%r@%h_id_rsa
User git
Test
$ ssh -Tv [email protected]
Now the remote host name wont change but if it did change this would just mean that the corresponding IdentityFile name would then be wrong.
debug1: Authenticating to github.com:22 as 'git'
debug1: Offering RSA public key: ~/.ssh/[email protected]_id_rsa
Using percent_expand for the remote host name %h is not going to work for naming the identity file. This will always need to be hard coded if you want it to differ from the remote host name used to authenticate.
The best i could come up with is this.
#Set Git User Domains
Host *-github.com *-bitbucket.org *-bitbucket.com
User git
#IdentityFile
Host tarranjones-*
IdentityFile ~/.ssh/tarranjones@%h_id_rsa
Host otherusername-*
IdentityFile ~/.ssh/otherusername@%h_id_rsa
#Hostnames
Host *-github.com
Hostname github.com
Host *-bitbucket.com *-bitbucket.org
Hostname bitbucket.org
Host *
Protocol 2
UseKeychain yes
AddKeysToAgent yes
IdentitiesOnly yes
Usage
$ ssh -Tv tarranjones-github.com
Result
debug1: Authenticating to github.com:22 as 'git'
debug1: Offering RSA public key: ~/.ssh/[email protected]_id_rsa
Please see Updated Gist