tags |
howto |
secure |
remote |
network |
ssh |
|
1. 기존에 만든 키가 있는지 확인
# 키 저장 위치로 이동
cd ~/.ssh
# 디렉터리 확인
dir
# result
# -a--- 2024-04-26 오후 9:50 1876 id_rsa
# -a--- 2024-04-26 오후 9:50 406 id_rsa.pub
# id_rsa.pub 파일이 존재하면 미리 생성해둔 키가 있는 것
# 키가 없다면 다음 1번부터 진행
2. 공개키-개인키 생성
- 커맨드라인
```powershell
ssh-keygen
```
- 콘솔 Output
```
Generating public/private rsa key pair.
Enter file in which to save the key (/home/path/.ssh/id_rsa):
Created directory '/home/path/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/path/.ssh/id_rsa
Your public key has been saved in /home/path/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:gYvoovB17rxedtSrKNblhVQut2llh7N18uegR+2Z10M tuska@DESKTOP-6TUO5I7
The key's randomart image is:
+---[RSA 3072]----+
| |
| . . |
| . . o . |
| . . . .o.o * +|
| . . . S..+.= O.|
| . .o =.+E+|
|o . . ..oo.o.o.+=|
|oo . +oo.o... .+=|
|. . +*o. . . o|
+----[SHA256]-----+
```
3. 생성한 공개키 Server로 전송하기
type $env:[public key path] | ssh [username]@[remote-host] "cat >> .ssh/authorized_keys"
4. ssh 접속
ssh [username]@[remote-host]