SSH Key Generation and How to use Multiple Keys
Key Generation
ssh-keygen -t rsa -C "your.email@example.com" -b 4096
File with .pub is the public key,
another on is the private key
Multiple Keys
When having multiple SSH keys(for different accounts) under the same domain (gitlab.com or github.com), system will not be able to detect which one to use. Therefore, it requires to have a config file directing the correct key for various user account
Host tagone
User git
Hostname gitlab.com
IdentityFile ~/.ssh/privatekeyone
Host tagtwo
User git
Hostname gitlab.com
IdentityFile ~/.ssh/privatekeytwo
Then when trying to connect to remote git repository, using tagone or tagtwo to replace hostname (git@gitlab.com)
git clone tagone:username/project.git
Server Side
Register public key in the server: copy and paste the public key at the bottom of the following file.
sudo vim ~/.ssh/authorized_keys