개요
: A 서버에서 RSA키를 생성하여 B 서버로 보내고 B 서버에서 A 서버로 SSH 접속
1. A서버 SSH 세팅
vi /etc/ssh/sshd_config
: Port 22
: PubkeyAuthentication yes
: PasswordAuthentication yes
service ssh restart
passwd root
2. A서버 RSA키 생성
ssh-keygen -t rsa -b 4096 -C "tlgns7386@gmail.com"
ls -al ~/.ssh
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
cd ~/.ssh
chmod 700 ~/.ssh
cat ~/.ssh/id_rsa
3. B서버 SSH 세팅
vi /etc/ssh/sshd_config
: Port 22
: PubkeyAuthentication yes
: PasswordAuthentication yes
: PermitRootLogin yes
service ssh restart
passwd root
passwd deploier
4. A 서버에서 B 서버로 공개키 전송 <A서버 콘솔에서 실행>
ssh-copy-id root@B_서버_아이피
5. B 서버에서 A 서버로 SSH 접속 <B서버 콘솔에서 실행>
ssh -l 사용자_계정 -p A서버_SSH_포트 A_서버_IP
접속 오류 해결방법
: 두 서버의 파일들을 다음과 같이 설정
: 없는 파일은 무시 (필요할 경우 생성 후 cat id_rsa.pub >> authorized_keys와 같이 옮길 것)
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
chmod 644 ~/.ssh/known_hosts
chmod 600 ~/.ssh/authorized_keys
Refference
공개키 인증으로 SSH Password 없이 접속하기
공개키 인증으로 SSH Password 없이 접속하기 SSH Key 만들기 SSH Key를 통해서 서버에 접속시 Unix 계열에서는 ssh-keygen 명령어를 이용하면 된다. Window OS에서는 SSH Client 프로그램이 자체적으로 생성 제공
blog.secuof.net
암호 없이 ssh-keygen & ssh-copy-id 사용하여 SSH 로그인 수행 3단계
원격 리눅스 서버에 암호 입력 없이 로그인 할 수 있습니다. 간단한 3단계 절차를 진행하면 되는데 ssky-keygen 사용과 이 글에서 설명하고 있는 ssh-copy-id 입니다. ssh-keygen 은 공용과 개인 키들을 생
itzone.tistory.com
'Container > Docker' 카테고리의 다른 글
다시 정리해 보는 Docker - 명령어 편 (컨테이너 / 이미지 / 네트워크 관리) (0) | 2021.10.15 |
---|---|
다시 정리해 보는 Docker - 개념편 (0) | 2021.10.15 |
도커 컨테이너 관련 꿀팁 모음 (0) | 2021.10.03 |
도커 네트워크 구조 (0) | 2021.09.21 |
도커 이미지 상태에서 컨테이너 터미널 접속 (0) | 2021.09.09 |