(Aws) 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 the key (/home/aaa/.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


댓글

이 블로그의 인기 게시물

(네트워크)폴링방식 vs 롱 폴링방식

(ElasticSearch) 결과에서 순서 정렬

(18장) WebSocekt과 STOMP를 사용하여 메시징하기