If you don’t want to execute git command with password, you can do the following:

  1. ssh-keygen -t rsa -b 4096 -C "[email protected]" -f ~/path/key1
  2. ssh-keygen -t rsa -b 4096 -C "[email protected]" -f ~/path/key2
  3. vi ~/.ssh/config
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    
    # github.com
    Host github.com
        HostName github.com
        User $username
        IdentityFile ~/path/key1
    
    # gitlab.com
    Host gitlab.com
        HostName gitlab.com
        User $username
        IdentityFile ~/path/key2
    
    Note: you can distinguish different repository with custom Host, then you should replace HostName with Host.
  4. if you configure it in windows, maybe you need to configure the ssh-agent
    1
    2
    3
    4
    
    $ eval "$(ssh-agent -s)"
    $ ssh-add ~/path/key1
    $ ssh-add ~/path/key2
    $ ssh-add -l    # do this for ensure had add correctly
    

Now you can use git protocol without password. Just test as following:

1
2
$ ssh -T [email protected]
$ ssh -T [email protected]