ssh

bastion server를 이용 하여 DB 접속 하는 설정

  • 한줄로 실행

ssh -i ~/.ssh/kth.pem -fNL (localhost생략)3306:kth-rds-writer.cds4.ap-northeast-2.rds.amazonaws.com:3306 ec2-user@52.79.xxx.xxx
  • ec2 -> bastion 서버이고

  • rds-writer는 db 서버이다.

  • kth.pem은 베스천서버의 pem key이다

이상태는 터널링이 맺어진 상태이며 mysql -h localhost 실행

그러나 위의 방법은 명령어가 너무 길어서 불편하다.

~/.ssh/config 설정 이후 편하게 사용 하자

Host pdb-proxy
    HostName 52.79.xxx.xxx
    User ec2-user
    IdentityFile ~/.ssh/kth.pem
    LocalForward 3306 kth-rds-writer.cd.ap-northeast-2.rds.amazonaws.com:3306
    ExitOnForwardFailure yes
    ServerAliveInterval 600
  • 실행

ssh -fN pdb-proxy                                                    

Last updated