I have different users for different github organizations, each with their own ssh keys. How can I easily switch between ssh keys for different accounts?
            Asked
            
        
        
            Active
            
        
            Viewed 313 times
        
    -3
            
            
        - 
                    https://stackoverflow.com/search?q=%5Bgithub%5D+multiple+accounts – phd Feb 27 '21 at 23:54
1 Answers
2
            
            
        Its quite possible with a little configuration in the ~/.ssh/config file.
The trick is - the Host in the .ssh config does not have to be the real Hostname
# add the ~/.ssh/id_altUsername file for the new user on Github
# ssh -T git@github-altUsername # test it can connect
# git clone git@github-altUsername:alt_username/[repo].git
Host github-altUsername
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_altUsername
    IdentitiesOnly yes
 
    
    
        Alister Bulman
        
- 34,482
- 9
- 71
- 110
 
    