마짱짱의 지식창고
SSH Key-gen을 통해 Server-Client 접속테스트 본문
1. User 분리하여 접근할 VM(Server) 접속
2. root 권한
sudo -i
3. User생성(test01)
useradd test01
(추가) useradd 후 /home/[User] 가 생성 되지 않았다면
mkhomedir_helper [User]
4. 비밀번호 설정
passwd test01
---
5. 사용자변경
su - test01
비밀번호입력
6. .ssh 폴더 만들기
mkdir .ssh
7. .ssh 권한변경
chmod 700 .ssh
8. Key 생성
ssh-keygen 실행 후 default 값으로 생성
id_rsa , id_rsa.pub 생성완료
9. 퍼블릭키 이름 변경
mv id_rsa.pub authorized_keys
10. authorized_keys 권한변경
chmod 600 authorized_keys
11. 프라이빗키 복사
cat id_rsa 해서 나온 내용 복사
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEA2UPW6z2As7mk+S0+G91Hbtg99kjtw5TCCT5JgQo7KstC1fWA1v6e
ooiKdl2WE8HksAC09VvMsJKplZWy8+J7yguV6IU+i7UbfuaEnOAebQscbpWQ0pMIBkhqJ5
BNoL//I4fn4nl5I91D+yvIG51P+zO/zyhsL/AA0KCQXrtNAp6I1z7ZLWU5gVlWLkKZl0BR
losq8Qf6VlgpKqqBXQoTANYcHI9HdoNPkdnJR/Nd1vZAmXF/bl90yYWMt0gIYOm+IeHX7w
8ZYKopLE7cJCIo/sxXKeoCxMH3vGBahkWB1NCOqd0mGLdTdFw9J1CKuZ7dCLDH1O9ww6CP
kmkrzqwX이렇게 길게 나온거 다 복사gtCgwq
3xQjawlmKZJgGuzx+Sb5xk+XTUpi/RAAAAwQDhvMbir+v9XsXmlHgpiXO1tPirYxdmsys4
fnVgD6bdk4rhFzKbyYQL9qvSU5+fURk63KUJ4/pG9+0noFaiI5fX8q9Hdzm9yU+z5QYrDE
CBat0Zt/QBwLP+Foe2wD3RRQ6WFWjAO2muPoFvK98zkBNyfgS4WiI9tA/cP843jUw5CiPE
YN8jNjBMleGCahf5s0YfcCFttDaRYRmmvIl2yR+CS6fBPXrA4IF3BXFRZbsqFA2aYF4kPh
WzF6SzH5H1vIkAAAAnY2xvb2N1cy1hZG1pbkBqdW1wYm94LWNsb29jdXMubm92YWxvY2Fs
AQIDBA==
-----END OPENSSH PRIVATE KEY-----
이제 Server 로 접근할 VM(Client)
11. .ssh 폴더 접근
cd .ssh
12. Private Key(test-key) 내용 붙여넣기
vi test-key
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEA2UPW6z2As7mk+S0+G91Hbtg99kjtw5TCCT5JgQo7KstC1fWA1v6e
ooiKdl2WE8HksAC09VvMsJKplZWy8+J7yguV6IU+i7UbfuaEnOAebQscbpWQ0pMIBkhqJ5
BNoL//I4fn4nl5I91D+yvIG51P+zO/zyhsL/AA0KCQXrtNAp6I1z7ZLWU5gVlWLkKZl0BR
losq8Qf6VlgpKqqBXQoTANYcHI9HdoNPkdnJR/Nd1vZAmXF/bl90yYWMt0gIYOm+IeHX7w
8ZYKopLE7cJCIo/sxXKeoCxMH3vGBahkWB1NCOqd0mGLdTdFw9J1CKuZ7dCLDH1O9ww6CP
kmkrzqwX이렇게 길게 나온거 다 붙여넣기gtCgwq
3xQjawlmKZJgGuzx+Sb5xk+XTUpi/RAAAAwQDhvMbir+v9XsXmlHgpiXO1tPirYxdmsys4
fnVgD6bdk4rhFzKbyYQL9qvSU5+fURk63KUJ4/pG9+0noFaiI5fX8q9Hdzm9yU+z5QYrDE
CBat0Zt/QBwLP+Foe2wD3RRQ6WFWjAO2muPoFvK98zkBNyfgS4WiI9tA/cP843jUw5CiPE
YN8jNjBMleGCahf5s0YfcCFttDaRYRmmvIl2yR+CS6fBPXrA4IF3BXFRZbsqFA2aYF4kPh
WzF6SzH5H1vIkAAAAnY2xvb2N1cy1hZG1pbkBqdW1wYm94LWNsb29jdXMubm92YWxvY2Fs
AQIDBA==
-----END OPENSSH PRIVATE KEY-----
13. 접근확인
ssh -i .ssh/test-key test01@[ServerIP]
'Linux' 카테고리의 다른 글
Ubuntu(WSL) Zsh 설치 및 테마, 편한 플러그인 설정 (0) | 2024.03.29 |
---|---|
NFS Server 설정, NFS Client 설정 스크립트 (0) | 2024.01.26 |
Debian locale ko_KR.UTF-8 한글팩 적용 안될때 (0) | 2022.06.28 |
[Git] 한번도 사용하지 않는 자의 Github에 commit 하기 (0) | 2022.01.19 |
ZFS 의 주요기능(cow, checksum, RAID-Z..등등) (0) | 2021.01.13 |