티스토리 뷰
ssh -i pem 키_파일 EC2_탄력적_IP_주소
위의 명령어로 외부 서버로 SSH 접속을 할 수 있다.
하지만 매번 명령어를 입력해야 하므로 키페어 파일을 ~/.ssh/ 로 복사하면 ssh 실행시 pem 키 파일을 자동으로 읽어 접속한다.
cp pem 키_파일 ~/.ssh/
위의 명령어를 입력하면 된다.
하지만 나는 ~/.ssh/ 디렉토리가 없었고 생성해야했다.
https://superuser.com/questions/1256286/missing-ssh-folder-in-macos-high-sierra
Missing ~/.ssh Folder in macOS High Sierra
I'm trying to find my ~/.ssh folder, but can't. I'm familiar with terminal so I've been going through my filesystem and can't find it anywhere. Has it relocated in the file tree or is my computer j...
superuser.com
위의 사이트를 참고하여 ~/.ssh/ 디렉토리를 생성하면 된다.
ssh-keygen
위의 명령어를 입력하면 입력을 해야한다.
“Enter file in which to save the key (/Users/your-username/.ssh/id_rsa)”에는 그냥 엔터를 입력하면 된다.
“Enter passphrase (empty for no passphrase):”에도 아무 것도 입력하지 않고 엔터를 눌러도 되지만
입력하는 것이 권장된다.
이렇게 ~/.ssh/를 만들고 다시 키 파일을 ~/.ssh/ 디렉토리에 복사하면 된다.
근데 다운 받았던 파일을 보면 (파일이름).cer인 것을 볼 수 있다.
분명 pem으로 다운받아도 확장자명이 cer인 것을 확인할 수 있다.
converting .cer to .pem returns error 'unable to load certificate'
I got an email containing a cert, it looked something like: -----BEGIN CERTIFICATE----- MIIHE... -----END CERTIFICATE----- I copy/pasted that into notepad and saved it as a .cer file. What I need...
stackoverflow.com
위의 글을 참고하면 이미 pem 포맷이고 그냥 이름을 변경하면 된다 했다.
mv file_name.cer file_name.pem
위의 명령어를 통해서 파일의 이름을 바꿔주면 된다.
위에서 언급했던 방법으로 pem 파일을 cp 명령어를 통해서 ~/.ssh 디렉토리로 복사한다.
그다음 pem 키의 권한을 600으로 변경한다.
chomod 600 ~./.ssh/file_name.pem
chomod 700 config
config 파일을 생성해주고 이미지와 같이 입력한다.
Host 뒤에는 서비스의 이름을, HostName은 연결한 탄력적 IP를, IdentityFile에는 pem 파일을 입력한다.
그다음 config 파일의 권한을 700으로 설정한다.
ssh config에_입력한_서비스_이름
그다음 터미널에 ssh명령어 뒤에 config 파일에서 Host 뒤에 입력했던 서비스 이름을 적고 실행한다.
짜잔! EC2에 접속이 성공하였다.
터미널에 ssh + 서비스 이름 이렇게 입력하면 실행할 수 있다.
이 서비스를 끝내고 싶다면 (control 키 + D)를 입력하면 된다.
- Total
- Today
- Yesterday
- java
- go 특징
- mysql
- postman
- Python
- 1차 인터뷰
- DGS Framework
- 코딩테스트
- string
- graphql
- postman collection
- pm.test
- Squash and merge
- hashcode
- downTo
- 주생성자
- 확장 함수
- Kotlin In Action
- squash merge
- postman tests
- github
- Basic Type
- 네이버 2022 공채
- git
- pm.expect
- 2차 인터뷰
- solidity
- 코틀린
- python3
- Kotlin
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |