Philographer

AWS Key Pair를 만든 후(pem 파일) ubuntu계정으로 접속한 다음에 sudo명령으로 root 권한 획득하기

1. ssh - i testkey.pem ubuntu@xxx.xxx.xxx.xxx
2. sudo su - 
3. whoami
=> 출력결과 root

SSH 키페어를 이용한 계정 관리

SSH 키페어는 ssh-keygen이라는 프로그램으로 만들 수 있다. 내 PC 이름이 my-pc이고 접근하려는 서버의 이름이 remote -pc라고 가정하자. 다음과 같이 rsa 키를 만들 수 있다.

my-pc # ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save th key(/home/yundream/.ssh/id_rsa):remote-pc
Enter passphrase (empty for no passphrase):

명령을 실행하면 작업 디렉토리에 remote-pc와 remote-pc.pub 파일이 생긴다.
remote-pc가 개인키이고 remote-pc.pub가 공용키이다. 이 공용키를 접근하려는 운영체제의 유저 홈 디렉토리에 복사하면 된다.
remote-pc에 test 라는 계정으로 접근하고 싶다면 test 계정을 만든 다음 .ssh디렉토리에 authorize_keys파일을 만들고 여기에 id_rsa.pub파일의 내용을 추가하면 된다.

remote-pc # adduser test
remote-pc # cd /home/test
remote-pc # mkdir .ssh
remote-pc # cat remote-pc.pub >> .ssh/authorized_keys

이제 개인키 파일을 이용해서 remote-pc에 접근할 수 있다.

remote-pc # ssh -i remote-pc test@remote-pc

'System > AWS' 카테고리의 다른 글

EC2 Deploy  (0) 2015.11.09
댓글 로드 중…

트랙백을 확인할 수 있습니다

URL을 배껴둬서 트랙백을 보낼 수 있습니다