Skip to content

Instantly share code, notes, and snippets.

@Aleksey-Voko
Last active October 21, 2021 11:42
Show Gist options
  • Save Aleksey-Voko/9bdf98f25290a796f17660705722509c to your computer and use it in GitHub Desktop.
Save Aleksey-Voko/9bdf98f25290a796f17660705722509c to your computer and use it in GitHub Desktop.
More than one ssh account per host

More than one ssh account per host

account 1:
Mr. Putin
[email protected]

account 2:
Mr. Trump
[email protected]


ssh-key generation for Mr. Putin

... do not forget to specify the file name ...

> cd ~/%userprofile%/.ssh/
> ssh-keygen -t rsa -b 4096 -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (~/%userprofile%/.ssh/id_rsa): id_rsa_MrPutin  # specify the file name
Enter passphrase (empty for no passphrase):  # can skip
Enter same passphrase again:  # can skip
Your identification has been saved in id_rsa_MrPutin.
Your public key has been saved in id_rsa_MrPutin.pub.
The key fingerprint is:
SHA256:nmdZJF5z1Gry/2Zfmrputin2jZX+2deQwXU33Q25aBI [email protected]
The key's randomart image is:
+---[RSA 4096]----+
|              o=B|
| ...o+ooo.+..    |
|     ..+.++o     |
|  ..++o=O.       |
|        S [email protected]|
|      . . o o.*= |
|      o   +   .oO|
|      o     oB   |
|               o*|
+----[SHA256]-----+

Two files created:
id_rsa_MrPutin - private key (without extension)
and
id_rsa_MrPutin.pub - public key


ssh-key generation for Mr. Trump

... do not forget to specify the file name ...

> cd ~/%userprofile%/.ssh/
> ssh-keygen -t rsa -b 4096 -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (~/%userprofile%/.ssh/id_rsa): id_rsa_MrTrump  # specify the file name
Enter passphrase (empty for no passphrase):  # can skip
Enter same passphrase again:  # can skip
Your identification has been saved in id_rsa_MrTrump.
Your public key has been saved in id_rsa_MrTrump.pub.
The key fingerprint is:
SHA256:EssBed6AYMP/afjmrtrumpgvkvVFRwTjXHm/Q0bAA18 [email protected]
The key's randomart image is:
+---[RSA 4096]----+
| .+..ooo++..E    |
|          E  o..X|
|   . o=+ ..+     |
|    ..o+o   +    |
|     ++oS     o .|
|  . . =.o        |
| o.. *       .   |
|  +oo   .o =     |
|o oo  +o+   ..+o |
+----[SHA256]-----+

Two files created:
id_rsa_MrTrump - private key (without extension)
and
id_rsa_MrTrump.pub - public key


Config file

Create a file ~/%userprofile%/.ssh/config :

# Github for "Mr. Putin"
Host mrputin.github.com  # 'github.com' change to 'mrputin.github.com'
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_MrPutin

# Github for "Mr. Trump"
Host mrtrump.github.com  # 'github.com' change to 'mrtrump.github.com'
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_MrTrump

Connection

Connection for Mr. Putin
[email protected]:MrPutin/foreign_policy.git
change to:
[email protected]:MrPutin/foreign_policy.git

Connection for Mr. Trump
[email protected]:MrTrump/domestic_policy.git
change to:
[email protected]:MrTrump/domestic_policy.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment