FTP(File Transfer Protocol) + 실습
2025. 1. 25. 21:37ㆍAWS Cloud School 8기
✅ FTP(File Transfer Protocol)
- 파일 전송 프로토콜
- TCP
- ftp 관련 디렉터리: /var/ftp
포트
- 세션 수립: 21
- 데이터 전송: 20
장점
- 신뢰성 있는 파일 전송
🧪 FTP 실습
1️⃣ FTP Server
1. VM 생성
- name: ftp-server
- Network: VMnet8
- IP: 211.183.3.21
- GW: 211.183.3.2
✔️ 기본 설정
더보기
1. firewalld 비활성화 & Selinux 제거
systemctl stop firewalld & systemctl disable --now firewalld & sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
2. yum repo 추가
cat <<EOF > /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/os/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/updates/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/extras/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/centosplus/x86_64/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/contrib/x86_64/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF
4. reboot
reboot
2. ftp server 패키지 설치
yum install -y vsftpd
3. vsftpd 활성화
systemctl restart vsftpd
systemctl enable vsftpd
⚠️ 활성화 안하면 오류발생 → Client에서 ftp 접속 불가능
4. FTP 서버를 위한 디렉터리 학인
ls /var/ftp
5. FTP 테스트 파일 생성
touch /var/ftp/ftp-test.txt
echo 'ftp-test file' > /var/ftp/ftp-test.txt
2️⃣ FTP Client
1. VM 생성
- name: ftp-client
- Network: VMnet8
- IP: 211.183.3.20
- GW: 211.183.3.2
✔️ 기본 설정
더보기
1. firewalld 비활성화 & Selinux 제거
systemctl stop firewalld & systemctl disable --now firewalld & sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
2. yum repo 추가
cat <<EOF > /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/os/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/updates/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/extras/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/centosplus/x86_64/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
baseurl=https://vault.centos.org/7.9.2009/contrib/x86_64/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF
4. reboot
reboot
2. FTP Client 관련 패키지 설치
yum install -y ftp
3. FTP 접속하기
ftp 211.183.3.21
- user1으로 접속하기
- Name: anonymous
- Password: (Enter)
4. FTP Server의 /var/ftp 경로의 내용 보기
ftp > dir
5. 파일 다운로드
ftp > get ftp-test.txt
6. FTP 종료하기
ftp > quit
7. 받은 ftp-test.txt 파일 확인
- client의 /root 디렉토리에 저장됨
[root@ftp-client ~]# ls
💡 접속 host에 따라 루트디렉토리가 변경됨!!
1️⃣ anonymous로 접속 후 dir 명령어 입력
FTP Server의 /var/ftp 경로의 내용 볼 수 있음
- /var/ftp는 공유폴더 느낌
2️⃣ user1으로 접속 후 dir 명령어 입력
user1의 홈 디렉토리(/home/user1) 경로의 내용을 볼 수 있음
✔️ FTP Server
- /home/user1에 test-user.txt 생성
✔️ FTP Client
- ftp 접속해보기
Name: user1
Password: user1
- dir
root로 접속하지 않은 이유?
FTP Server에서 user1의 홈 디렉토리에 파일을 생성했기 때문이다!!
사용자마다 홈 디렉터리가 다름!!!
❓anonymous로 접속하면 user1의 홈 디렉토리로 이동할 수 있을까?
✅ 결론: 안됨!!!
🧪 테스트 방법
1. anonymous로 접속
2. /home/user1으로 이동Failed to change directory.
3. pwd 확인
💡 알아낸 것!!
anonymous로 접속시 → 루트 디렉터리: /var/ftp
user1으로 접속시 → 루트 디렉터리: /home/user1
'AWS Cloud School 8기' 카테고리의 다른 글
Reverse Proxy Server 실습 (4) | 2025.02.04 |
---|---|
PxE(Preboot eXecution Environment) + 실습 with FTP, TFTP, DHCP, HTTP (1) | 2025.01.27 |
TFTP(Trival FTP) + 실습 (2) | 2025.01.25 |
NFS(Network File System) (4) | 2025.01.25 |
네트워크) VLAN을 활용한 서버 통신 (4) | 2025.01.05 |