키 기반 인증
id.rsa
키 생성
개인키, 공개키
공개키를 서버에게 넘겨줌
ssh-keygen
: 키 생성
ssh-copy-id
: 키 복사
vim .ssh/id_rsa.pub
: 생성한 공개키? 확인 가능
vim .ssh/authorized_keys
: 복사해서 넘겨받은? 공개키? 확인 가능
**$ ssh-keygen**
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/user/.ssh/id_ed25519):
Enter passphrase for "/home/user/.ssh/id_ed25519" (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_ed25519
Your public key has been saved in /home/user/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:nJjFe5QDjTQSuj+h7XcQwNMUkvJSFP2isSiVfmjMUO8 user@test1
The key's randomart image is:
+--[ED25519 256]--+
| o*O*+ |
| o.*++o.. |
| ..* oo.+ |
| . +.+=o+.. |
| *.=++So. |
| . B+E... |
| o..+ . |
| . .. . |
| .. . |
+----[SHA256]-----+
$ ssh-copy-id user@192.168.56.101
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/user/.ssh/id_ed25519.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
user@192.168.56.101's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'user@192.168.56.101'"
and check to make sure that only the key(s) you wanted were added.
$ ssh user@192.168.56.101
Web console: https://test2:9090/ or https://192.168.0.190:9090/
Last login: Fri Aug 22 10:10:54 2025 from 192.168.56.1
user@test2:~$ exit
logout
Connection to 192.168.56.101 closed.
$ vim .ssh/id_rsa.pub
$ vim .ssh/id_ed25519.pub
**$ ssh-keygen -f .ssh/key-with-pass**
Generating public/private ed25519 key pair.
Enter passphrase for ".ssh/key-with-pass" (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in .ssh/key-with-pass
Your public key has been saved in .ssh/key-with-pass.pub
The key fingerprint is:
SHA256:zCqnzv2L7XPWr2LHfRRc8aEbzQ1g9ajDOfFJqKufRYU user@test1
The key's randomart image is:
+--[ED25519 256]--+
| oooo.|
| . o++=|
| Eo=o=|
| o o Bo+ |
| S . B.o .|
| . o o .|
| . o .o.. . |
| . = o..=o+ . .|
| .+ oo*Boo.o.. |
+----[SHA256]-----+
**$ ssh-copy-id -i .ssh/key-with-pass.pub user@192.168.56.101**
passphrase?
ssh -i .ssh/key-with-pass user@192.168.56.101
→ 직접 설정한 키라면 이렇게 복사해야 한다?
→ 이 이후에는 비밀번호 입력하지 않아도 로그인 가능?
vim .ssh/key-with-pass.pub
vim .ssh/authorized_keys
→ 정상적으로 키가 추가됐는지 확인
개인키는 소유자빼고는 읽기 권한이 있어서는 안됨.
→ 400 or 600 만 가능
ssh-agent
[user@test1 ~]$ echo $ssh-agent
-agent
[user@test1 ~]$ eval $(ssh-agent)
Agent pid 1757
[user@test1 ~]$ ssh-add .ssh/key-with-pass
Identity added: .ssh/key-with-pass (user@test1)
[user@test1 ~]$ ssh -i .ssh/key-with-pass user@192.168.56.101
Web console: https://test2:9090/ or https://10.0.2.15:9090/
Last login: Fri Aug 22 10:56:06 2025 from 192.168.56.1
user@test2:~$
/etc/ssh/sshd_config
→ root 로의 로그인은 비밀번호를 금지
$ ssh [root@192.168.56.101](mailto:root@192.168.56.101)
[root@192.168.56.101](mailto:root@192.168.56.101)'s password:
**Permission denied**, please try again.
scp (Secure Copy): ssh 기반 복사
: 위치를 정확하게 인지하고 있어야 함
→ 윈도우에서 리눅스로, 리눅스에서 윈도우로 파일을 복사하고 싶을 때
scp [파일 위치] [복사할 위치]
# ssh 기반이므로 user@ip주소 방식 똑같이
# 디렉토리 위치와의 구분자 **:**
$ scp fileA user@192.168.56.101:/home/user/
[user@test1 ~]$ scp fileA user@192.168.56.101:/home/user/
fileA 100% 0 0.0KB/s 00:00
user@test2:~$ ls
Desktop Downloads Music Public Videos
Documents **fileA** Pictures Templates
→ 다른 원격 환경에? 붙여넣기 가능
[user@test1 ~]$ scp user@192.168.56.101:/home/user/fileB .
[user@test1 ~]$ ls
fileA fileB
→ 반대로 가져오기도 가능
sftp (Secure File Transfer Protocol): ssh 기반 복사
: 대화형
: 클라이언트 위치 고정
# 접속하면 대화형으로 시작
[user@test1 ~]$ sftp user@192.168.56.101
Connected to 192.168.56.101.
sftp>
# 접속한 환경의 작업 디렉토리 확인 가능
sftp> ls
Desktop Documents Downloads Music Pictures Public
Templates Videos fileB
sftp> pwd
Remote working directory: /home/user
# fileB 를 복사해서 가져옴
sftp> get fileB
Fetching /home/user/fileB to fileB
# fileA를 복사해서 넘김
sftp> put fileA
Uploading fileA to /home/user/fileA
fileA 100% 0 0.0KB/s 00:00
# 종료
sftp> exit
[user@test1 ~]$ ls
fileA **fileB**
→ 파일 위치를 잘 모를 때 cd 로 움직여가며 해당 파일을 복사해서 가져올 수 있음
패키지
: 설정 파일 + 실행 파일
| RPM | YUM | DNF | |
|---|---|---|---|
| 온프레미스(로컬) | |||
| → 최신 패키지 수동 설치 가능 | 네트워크 | ||
| → 정식 패키지 | apt | ||
| .rpm | .rpm | ||
| 종속성 문제 | 종속성 문제 해결 |
rpm
dnf list
: 패키지 목록 확인
dnf search
: 패키지를 키워드로 검색
dnf info
: 패키지의 정보를 확인할 수 있음
**$ dnf info httpd**
Last metadata expiration check: 0:00:24 ago on Thu 21 Aug 2025 11:29:44 PM EDT.
Installed Packages
Name : httpd
Version : 2.4.63
Release : 1.el10
Architecture : x86_64
Size : 56 k
Source : httpd-2.4.63-1.el10.src.rpm
Repository : @System
From repo : appstream
Summary : Apache HTTP Server
URL : https://httpd.apache.org/
License : Apache-2.0 AND (BSD-3-Clause AND metamail AND
: HPND-sell-variant AND Spencer-94)
Description : The Apache HTTP Server is a powerful, efficient, and
: extensible web server.
dnf provides
: 디렉토리와 연관된 패키지 확인
dnf update
: 저장소 업데이트
dnf install
: 패키지 설치
dnf remove
: 패키지 제거
vim /etc/yum.repos.d/rocky.repo
→ 저장소 정보
[이름] - 사용자 편의 이름
name = 시스템에서 인식하는 저장소 이름
baseurl = 저장소 실제 위치 url
→ 주석처리 돼있어서 실제로는 mirrorlist가 구동 중
mirrorlist = 미러 저장소 (원본 저장소 패키지 내용 유사)
→ 실제 원본 서버에 부담이 갈 수 있기 때문에 baseurl 을 그대로 미러링해놓음
enabled = 0 or 1
gpgcheck = 0 or 1