Multiple SSH Key Management

#GitHub
ssh: Could not resolve hostname github.com:username: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
#Bitbucket
ssh: Could not resolve hostname bitbucket.org: Name or service not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

Creating SSH Key:

$ ssh-keygen -t rsa -b 4096 -C "your@email.com"
Generating public/private rsa key pair.  
Enter file in which to save the key (/home/emre/.ssh/id_rsa):
$ ssh-keygen  
Generating public/private rsa key pair.
Enter file in which to save the key (/home/emre/.ssh/id_rsa):
Created directory '/home/emre/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in //home/emre/.ssh/id_rsa.
Your public key has been saved in /home/emre/.ssh/id_rsa.pub.
The key fingerprint is:
4c:80:61:2c:00:3f:9d:dc:08:41:2e:c0:cf:b9:17:69 emre@myhost.local
The key's randomart image is:
+--[ RSA 2048]----+
|*o+ooo. |
|.+.=o+ . |
|. *.* o . |
| . = E o |
| o . S |
| . . |
| . |
| |
| |
+-----------------+
$ ls ~/.ssh
id_rsa id_rsa.pub
$ cat id_rsa
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAACFQAAAAdzc2gtcn
NhAAAAAwEAAQAAAf8rzyak4sv8oWg2j2XC3zdUogh2639L1UsHUog/8rICc/QnKAJeZrfI
vsHHm9u3mrCYojZ9YmnNNK1lrSdE5lZzfrqfcEkIkC93ghoW+ijEpPvcOpfp8UN9ikedpj
...
fQgfdDa31aFAAABxlbXJlLnlpbGRpcmlt3f5ADAgdAQHNhaGliaW5kZW4uY29tAQIDBA==
-----END OPENSSH PRIVATE KEY-----
$ cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB/yvPJqTiy/yhaDaPZcLfN1SiCHbrf0vVa
SwdSiD/ysgJz9CcoAl5mt8i+wceb27easJiiNn1iac00rWWtJ0TmVnN+up9wSQiQL3eC4
a2OZjbm0j79W9QDzSJtSBvpoRSyc+5jg6X2APtS/r+StOoeqAebMOrO3+ENtIkL2+97M5
....
afgZ1FAS0TrZGeQrvX0aXWagXZ856NoFHexNAaMems= emre.yildirim@mryldrm.com
clip < id_rsa.pub
pbcopy < ~/.ssh/id_rsa.pub
xclip -sel clip < ~/.ssh/id_rsa.pub

Define Multiple SSH

SSH Configuration

#root
Host root
HostName github.com
User root
IdentityFile ~/.ssh/id_rsa
IdentitiesOnly yes

#server1
Host server1
HostName bitbucket.org
User server1
IdentityFile ~/.ssh/server1
IdentitiesOnly yes
#server2
Host server2
HostName bitbucket.org
User server2
IdentityFile ~/.ssh/server2
IdentitiesOnly yes
...
Host *
IdentityFile ~/.ssh/id_rsa
IdentityFile ~/.ssh/server1

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store