R&D/클라우드

SSH Agent forwarding

sunshout 2017. 8. 18. 10:39

SSH Agent forwarding 은 Local PC 의 ssh key(private)를 통해서 Jumphost 뒤에 있는 리눅스 서버들에 접속하게 하는 방법이다.



+-------------+                  +-------------------+

| My PC(key) | --------------->|  jumphost         |

+-------------+                   +------------------+

                                               |

                     ----------------------+--------------------------

                    Server #1       Server #2             Server #N



- SSH Key는 MyPC에만 존재하고, jumphost 에는 존재하지 않는다.

- MyPC의 key를 통해서 Server #1 ~ #N 까지 접속한다.



ㅇ MyPC 에서 할 일


eval `ssh-agent -s`


ssh-add -K myPrivateKey.pem
Enter passphrase for myPrivateKey.pem:
Passphrase stored in keychain: myPrivateKey.pem
Identity added: myPrivateKey.pem (myPrivateKey.pem)


jumphost 에 ssh로 접속할 때는 -A 옵션을 준다.


ssh –A user@<jumphost or DNS-entry>


ㅇ Jumphost 에서



jumphost 에서 Server 에 접속 할 때도 -A 옵션을 준다.


ssh user@<instance-IP-address or DNS-entry>

참고

https://aws.amazon.com/ko/blogs/security/securely-connect-to-linux-instances-running-in-a-private-amazon-vpc/#more-848