Configure SSH for multiple hosts

In your .ssh directory you should have the following optional files:

File Description
authorized_keys List of public keys that can be used to ssh into current machine
config Configuration file for SSH
id_rsa Your private key, must have permissions 0600
id_rsa.pub Your public key, you add the content of this file into authorized_keys on servers/machines you want to have access to
To generate private and public key, run ssh-keygen command in your terminal.

Add the following code snippets into your ~/.ssh/config file:

Replace Git repository url

Host mygitlab
	HostName gitlab.com
    User my-gitlab-user
    IdentityFile ~/.ssh/my-gitlab-key
    IdentitiesOnly yes
    StrictHostKeyChecking no
    PreferredAuthentications publickey

Now, use an url like this to clone your repository:

git clone git@mygitlab:account/project.git

SSH to a server

Host my-server
	HostName xxx.xxx.xxx.xxx
    User myuser
    IdentityFile ~/.ssh/myserver
    IdentitiesOnly yes
    StrictHostKeyChecking no

Run command ssh my-server

Connect to IP range

Host 10.10.*.*
	User myotheruser
    IdentityFile ~/.ssh/myotherserver
    IdentitiesOnly yes
    StrictHostKeyChecking no

Disable Host checking

StrictHostKeyChecking no

Connect to a server using a jump host

Host webserver
	Hostname www.mywebserver.com
    HostKeyAlias www.mywebserver.com
    ProxyCommand ssh jump.server.com -W %h:%p

Source

Connect using ssh webserver