-
scp - secured copy protocol인프라/linux 2024. 3. 22. 19:19
aws에서 인프라를 구축하면서 ec2를 private subnet에 두고 외부에서 접근할 방법을 찾던 중 학습한 내용입니다.
Bastion Host 역할을 하는 ec2에서 private subnet의 ec2에 ssh로 접근하는 방법을 사용하고 있습니다.
나름의 Microsevice를 구축하면서 새로운 EC2를 private subnet에서 사용해야하는 상황입니다.
public ec2에서 private ec2로 ssh 통신을 하려고 하니 보안키가 필요한데, 보안키는 로컬 환경에 가지고 있습니다.
로컬에 있는 보안키를 어떻게 EC2로 옮길 수 있는지 찾아보니 scp 라는 프로토콜을 알게 되었습니다.
$ scp -i /path/to/your/bastion-key.pem /path/to/your/ec2-key.pem ec2-user@your-bastion-host-public-ip:/path/where/to/store
scp 역시 ssh를 기반으로 하고 있기 때문에 비슷한 형태로 사용되는 것을 볼 수 있습니다.
1. -i 에 파일을 보내고자하는 EC2에 ssh 접속을 위해 필요한 pem 키를 입력해 줍니다.
2. 전송하고자 하는 파일의 경로를 입력해줍니다.
3. 'ec2 접속 주소:저장될 주소' 와 같은 형태로 위치를 지정해줍니다.
반대로 ec2에 있는 파일을 로컬로 가져오는 것에도 사용할 수 있습니다.
감사합니다.
'인프라 > linux' 카테고리의 다른 글
자주 사용하는 리눅스 명령어 정리 (0) 2024.04.18 RHEL에서 port에 실행 중인 프로세스 확인하기 (0) 2024.04.12 Linux에서 사용자에 따른 환경변수 설정 (0) 2024.03.17 EC2 RHEL 9.3에서 htop 설치하기 (0) 2024.02.15 [이슈]REMOTE HOST IDENTIFICATION HAS CHANGED! (0) 2024.01.05