SSH 연결 설정을 저장하여 관리할 수 있게 해주는 config 파일 설정 방법
1. ssh config 설정
# vim ~/.ssh/config
Host bastion
HostName BASTION_SERVER_IP
# HostName 43.20.21.18
User BASTION_SERVER_ID
# User ec2-user
IdentityFile PATH_TO_PEM_KEY
# IdentityFile ~/.ssh/ec2-pem
2. ssh ProxyCommand 이용 내부 네트워크 서버 접속 설정
Bastion 서버(중간 호스트)를 통해 내부 네트워크(Private Subnet)의 목적지 호스트까지 연결할 때 사용
2.1 ProxyCommand 설정
# vim ~/.ssh/config
Host bastion
HostName BASTION_SERVER_IP
# HostName 43.20.21.18
User BASTION_SERVER_ID
# User ec2-user
IdentityFile PATH_TO_PEM_KEY
# IdentityFile ~/.ssh/ec2-pem
ForwardAgent yes
Host web-server
HostName WEB_SERVER_IP
# HostName 10.0.41.219
User WEB_SERVER_ID
# User ec2-user
ProxyCommand ssh -W %h:%p bastion
2.2 ssh agent 실행
eval $(ssh-agent -s)
2.3 ssh agent에 키 등록
ssh-add ~/PATH_TO_PEM_KEY
# ssh-add ~/.ssh/ec2.pem
3. ssh 접속 명령
ssh web-server
'Infrastructure & Systems > Linux' 카테고리의 다른 글
[Linux] cgroup (0) | 2025.03.13 |
---|---|
[Linux] system call, capability, access control (0) | 2025.03.13 |
[Linux] Server Command Logging (0) | 2024.11.23 |
[Linux] Syslog의 Facility와 Priority Level (1) | 2024.11.22 |
[Linux] iptables routing table 설정 (0) | 2024.11.21 |