2016년 5월 30일 월요일

How to using multiple SSH KEYS

Creat SSH KEY for server1

[root@linode ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
f9:99:30:0e:8d:cc:a1:44:c6:ac:19:6e:67:19:04:5a root@linode
The key's randomart image is:
+--[ RSA 2048]----+
|  E=+            |
| o.o+            |
|.. +.o.          |
|  =.++ + .       |
| . o. = S        |
|       o + o     |
|        . +      |
|                 |
|                 |
+-----------------+
[root@linode ~]# cat ./.ssh/id_rsa.pub | ssh -p10022 root@conoha.ivps.kr "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
The authenticity of host '[conoha.ivps.kr]:10022 ([133.130.126.29]:10022)' can't be established.
ECDSA key fingerprint is d1:33:b1:93:a0:7c:5b:7e:3b:e1:5b:2b:13:8a:27:01.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[conoha.ivps.kr]:10022,[133.130.126.29]:10022' (ECDSA) to the list of known hosts.
root@conoha.ivps.kr's password:


Creat SSH KEY for server2

[root@vultr ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
d1:22:15:0c:4e:d5:95:19:fd:c6:c8:4f:8b:5b:f8:01 root@vultr.ivps.kr
The key's randomart image is:
+--[ RSA 2048]----+
|      o++o .o=   |
|     o .... o .  |
|      o o .  . + |
|       . o   Eo =|
|        S     ++.|
|             o +.|
|              + .|
|             . . |
|                 |
+-----------------+
[root@vultr ~]# cat ./.ssh/id_rsa.pub | ssh -p10022 root@conoha.ivps.kr "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
The authenticity of host '[conoha.ivps.kr]:10022 ([133.130.126.29]:10022)' can't be established.
ECDSA key fingerprint is d1:33:b1:93:a0:7c:5b:7e:3b:e1:5b:2b:13:8a:27:01.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[conoha.ivps.kr]:10022,[133.130.126.29]:10022' (ECDSA) to the list of known hosts.
root@conoha.ivps.kr's password:


Checked in Backup server

[root@conoha ~]# cat ~/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3P6CFMztEsGJzLjGhoGNomDKAQ5CgnVW5eV79zRWTGdamxHtJLZS1sq5lCk4oFAslhD4fStQguH4TKVrhFhwczK+mIX7iaycUVJshH2QB4Zce4rM+7loacU1WKOjE1LK4twWggH8LsJHkwRqBaZi/9mXYbBsUpsnR1PvBxZ5ub+61jqujD13jgwMS9tlVSLsM9VFrn/+bMEt8bAwSeVCPlY2QroeL7euu/H6CwW4NYGEPXOEnu6k9W5WKSeBo+WjTsLvip/UziJ6+jjs2z+VGeg2iyOXBG6onXAnfa9vaY+gqQ6X5ZL2/5TFP9T1nYNlask2W6FlQhe09OpDDaVA1 root@linode.ivps.kr
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIacorFIiihlSc8fDOrZNab79w7STxi6ubNOAn+BsnBBKawMlWWEb6gzQTC0BTcZUQpm/s3LFQgQGdu5cfdVi+DfmicOQo9N+bjNLv/NHfoCt0yEWmlWDx2iew37Lv1BzrV/w1T2xssx7KVCrRg+NmcUbP0yPegtGsvjR17vpCafam7jxN2TRxo3uk7ah9z8budaKACMeOpF1JhEpMSahmHvweyUXNIpN3dnBnfZIUqwFFh+RnOY3rR2L2W9c0bc6KQSGpl0BavqeGrSNhYNwVYn2tcCGcDCePqrT4mFkG+QPxhpZmNNeNrlRS5NDB9FgBbVCUMuFtI7aD4qW7itI1 root@vultr.ivps.kr