본문 바로가기
Cloud/GCP

[GCP] Cloud IAP 설정으로 console SSH 서버 접속하기

by SystemAnswer 2022. 10. 13.
반응형

Google Cloud Platform에서는 별도의 Bastion Server나 SSH Tool(Putty)와 같은 프로그램이 없어도 GCP console 내에 "SSH"를 통해서 서버에 접근이 가능하다. GCP console에서 SSH로 접속하기 위해서는 GCP에서 IAP 관련 설정이 필요한데 이 부분을 하나씩 알아보자.

 

외부 IP 주소가 없거나 인터넷을 통해서 직접 액세스를 하지 않는 VM에 접근이 필요할 때 사용하면 된다.

 

GCP console에서만 접근이 가능하게 설정하면 console에 접근가능한 계정들에 한에서 권한을 부여하면 되기 때문에 보안성을 향상 시킬 수 있다.

 

 

구성 목표

GCP project에서 생성되어 있는 vpc network(vpc-demo)에 생성되는 VM instance 들은 모두 Cloud IAP를 사용하여 액세스 될 수 있도록 적용.

1. 대상 VPC : vpc-demo (172.22.36.0/24)

2. Cloud IAP 대상 : vpc-demo 내 모든 VM Instances

3. 방화벽 설정

    3.1 Name : firewall-demo-allow-ingress-from-iap

    3.2 Rule : Allow Ingress 22, 3389 port

    3.3 Source IP : 35.235.240.0/20 (Cloud IAP IP range)

    3.4 Target IP : All instances in the network (172.22.36.0/24 / vpc-demo)

4. Test Server : vm-demo-web (172.22.36.10)

 

Cloud IAP 구성 안될 경우 Error Messages

IAP에 대한 설정이 안되어 있으면 "SSH" 브라이저를 열게되면 아래와 같은 Error 메세지가 나타난다.

이럴 경우 아래 Cloud IAP 설정 방법을 따라하게되면 해결할 수 있다.

###

Please consider adding a firewall rule to allow ingress from the Cloud IAP for TCP forwarding netblock to the SSH port of your machine to start using Cloud IAP for TCP forwarding for better performance.

###

 

GCP Cloud IAP 설정 방법

1. Name : firewall-demo-allow-ingress-from-iap

2. Network : vpc-demo

    2.1 사용 중인 VPC를 선택 

3. Action on match : Allow

4. Targets : All instances in the network

    4.1 특정 VM만 해당 방화벽을 설정하려면 Targets을 "Specified target tags"로 설정하고 VM마다 tags 값을 넣어주면 된다.

5. Source fitter : IPv4 ranges

6. Soure IPv4 ranges : 35.235.240.0/20

7. Protocols and ports : Specified protocols and ports

    7.1 TCP : 22, 3389

8. 방화벽 설정 완료

 

IAP 적용 결과 (SSH-in-browser)

1. Test Server SSH 접속 결과

 

2. 방화벽 설정 결과

반응형

댓글