ssh
1. Create ssh keys
# create a key pair under .ssh
# ssh-keygen -t [name] -C "your_email@example.com"
ssh-keygen -t rsa -C "lin.chen@ieee.org" # create id_rsa and id_rsa.pub under .ssh directory
		
2. Edit config file
# GitHub.com
# .ssh/config
Host [github_name]
    HostName github.com
    IdentityFile ~/.ssh/[private_key_file_name]
    PubKeyAuthentication yes
    ServerAliveInterval 300
    TCPKeepAlive no
    User git
        
# GitLab.com
# .ssh/config
Host gitlab.com
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/[private_key_file_name]
        
3. Store passphrase in the keychain
ssh-add -K ~/.ssh/[private_key_file_name]
        
4. Add public key to github
# setting/SSH and GPG keys at GitHub.com
# profile/SSH Keys at GitLab.com
        
5. Add remote repository at github
# github account, lin-chen-Langley
git remote add origin git@github.com:lin-chen-Langley/[repository_name]

# gitlab, lin.chen2
git remote add origin git@gitlab.com:lin.chen2/[repository_name]
        
6. Push to repository
git push -u origin main
        
Reference
  • Generating a new SSH key and adding it to the ssh-agent