# MySql 터널링 - 개요 로컬 PC 에서 AWS 계정1 EC2 를 통하여 AWS 계정2 DB 에 연결하는 방법 AWS 계정1 과 AWS 계정2 는 VPC 피어링 되어 있다 - 방법 ssh -f -N -L (로컬 Port):(DB 주소):(DB Port) (EC2 계정)@(EC2 주소) -p (EC2 SSH Port) -i (EC2 .pem 경로) - 예시 - Window ssh -f -N -L 13306:dev-caliverse-db-instance-0.c3hsstp6l30g.ap-northeast-2.rds.amazonaws.com:3306 ubuntu@ec2-54-202-112-130.us-west-2.compute.amazonaws.com -p 2211 -i D:\ppk\us-west-2\USWest2-KeyPair.pem - Linux ssh -f -N -L 13306:dev-caliverse-db-instance-0.c3hsstp6l30g.ap-northeast-2.rds.amazonaws.com:3306 ubuntu@ec2-54-202-112-130.us-west-2.compute.amazonaws.com -p 2211 -i /mnt/d/ppk/us-west-2/USWest2-KeyPair.pem - 설명 로컬에서 MySql 주소를 127.0.0.1 13306 으로 연결을 하면 EC2 ubuntu@ec2-54-202-112-130.us-west-2.compute.amazonaws.com -p 2211 를 통하여 DB dev-caliverse-db-instance-0.c3hsstp6l30g.ap-northeast-2.rds.amazonaws.com:3306 로 접속한다. - pem 파일 설정 pem 파일 -> 속성 -> 보안 -> 고급 -> 상속 사용 안함 -> 적용 -> 확인 -> 편집 -> 로그인 한 계정이 없으면 추가 -> 로그인 한 계정을 제외한 그룹과 사용자 제거 -> 로그인 한 계정의 권한은 읽기만 ​