1. CentOS7
[ FTP 서버 ]
yum -y install vsftpd
mkdir -p /app/repo/ftp
chmod 775 /app/repo/ftp
chmod 777 /app/repo/ftp/upload
sed -i "s/^write_enable.*//g" /etc/vsftpd/vsftpd.conf
sed -i "s/^anon_upload_enable.*//g" /etc/vsftpd/vsftpd.conf
sed -i "s/^anon_root.*//g" /etc/vsftpd/vsftpd.conf
sed -i "s/^pasv_enable.*//g" /etc/vsftpd/vsftpd.conf
sed -i "s/^pasv_min_port.*//g" /etc/vsftpd/vsftpd.conf
sed -i "s/^pasv_max_port.*//g" /etc/vsftpd/vsftpd.conf
sed -i "/^$/d" /etc/vsftpd/vsftpd.conf
cat <<FTP_SERVER_SETTING >> /etc/vsftpd/vsftpd.conf
write_enable=YES
anon_upload_enable=YES
anon_root=/app/repo/ftp
pasv_enable=YES
pasv_min_port=30000
pasv_max_port=30009
FTP_SERVER_SETTING
# ftpusers 설정 파일에 등록된 유저는
# 패스워드 확인 후 거부
sed -i "s/^root.*//g" /etc/vsftpd/ftpusers
# user_list 설정 파일에 등록된 유저는
# 무조건 거부
sed -i "s/^root.*//g" /etc/vsftpd/user_list
firewall-cmd --permanent --add-port=21/tcp --add-port=30000-30009/tcp
firewall-cmd --reload
firewall-cmd --list-ports
getsebool -a | grep ^ftp
setsebool -P ftpd_anon_write 1
setsebool -P ftpd_connect_all_unreserved 1
setsebool -P ftpd_connect_db 1
setsebool -P ftpd_full_access 1
setsebool -P ftpd_use_cifs 1
setsebool -P ftpd_use_fusefs 1
setsebool -P ftpd_use_nfs 1
setsebool -P ftpd_use_passive_mode 1
systemctl restart vsftpd
systemctl enable vsftpd
[ 리눅스 클라이언트 ]
yum -y install ftp
# ftp 접속 확인을 위한 매크로 설치
yum -y install expect
echo Input Your FTP Server :
FTP_SERVER_IP=192.168.108.50 # read FTP_SERVER_IP
mkdir -p /app/tmp
cd /app/tmp
echo "This file was created by the linux ftp client" > /app/tmp/file01
echo "This file was created by the linux ftp client" > /app/tmp/file02
# 액티브 모드의 경우 데이트교환을 위해 20번포트로 클라이언트의 임의의 포트에게
# 데이터 연결 요청을 하기 때문에 클라이언트가 방화벽 설정이 되어 있을경우 데이터 교환이 되지 않음
systemctl stop firewalld
# 액티브 모드로 접속확인
expect <<EOF
spawn ftp -A -n ${FTP_SERVER_IP}
expect "ftp>"
send "quote USER root\n"
send "quote PASS P@ssw0rd!\n"
send "ls\n"
send "put file01\n"
send "ls\n"
send "cd /etc\n"
send "get passwd\n"
send "quit\n"
expect eof
EOF
systemctl start firewalld
# 패시브 모드로 접속확인
expect <<EOF
spawn ftp -p -n ${FTP_SERVER_IP}
expect "ftp>"
send "quote USER root\n"
send "quote PASS P@ssw0rd!\n"
send "ls\n"
send "put file02\n"
send "ls\n"
send "cd /etc\n"
send "get shadow\n"
send "quit\n"
expect eof
EOF
[ 윈도우 클라이언트 ]
2. Ubuntu20
[ FTP 서버 ]
apt-get -y install vsftpd
mkdir -p /app/repo/ftp
mkdir -p /app/repo/ftp/upload
chmod 775 /app/repo/ftp
chmod 777 /app/repo/ftp/upload
sed -i "s/^write_enable.*//g" /etc/vsftpd.conf
sed -i "s/^anonymous_enable.*//g" /etc/vsftpd.conf
sed -i "s/^anon_upload_enable.*//g" /etc/vsftpd.conf
sed -i "s/^anon_root.*//g" /etc/vsftpd.conf
sed -i "s/^pasv_enable.*//g" /etc/vsftpd.conf
sed -i "s/^pasv_min_port.*//g" /etc/vsftpd.conf
sed -i "s/^pasv_max_port.*//g" /etc/vsftpd.conf
sed -i "s/^userlist_enable.*//g" /etc/vsftpd.conf
sed -i "s/^userlist_file.*//g" /etc/vsftpd.conf
sed -i "s/^userlist_deny.*//g" /etc/vsftpd.conf
sed -i "/^$/d" /etc/vsftpd.conf
cat <<FTP_SERVER_SETTING >> /etc/vsftpd.conf
anonymous_enable=YES
write_enable=YES
anon_upload_enable=YES
anon_root=/app/repo/ftp
pasv_enable=YES
pasv_min_port=30000
pasv_max_port=30009
userlist_enable=YES
userlist_file=/etc/user_list
userlist_deny=YES
FTP_SERVER_SETTING
# ftpusers 설정 파일에 등록된 유저는
# 패스워드 확인 후 거부
sed -i "s/^root.*//g" /etc/ftpusers
echo >> /etc/user_list
# user_list 설정 파일에 등록된 유저는
# 무조건 거부
sed -i "s/^root.*//g" /etc/user_list
ufw allow 21/tcp
ufw allow 30000:30009/tcp
ufw reload
ufw status
systemctl restart vsftpd
systemctl enable vsftpd
[ 리눅스 클라이언트 ]
apt-get -y install ftp
# ftp 접속 확인을 위한 매크로 설치
apt-get -y install expect
echo Input Your FTP Server :
FTP_SERVER_IP=192.168.108.20 # read FTP_SERVER_IP
mkdir -p /app/tmp
cd /app/tmp
echo "This file was created by the linux ftp client" > /app/tmp/file01
echo "This file was created by the linux ftp client" > /app/tmp/file02
# 액티브 모드의 경우 데이트교환을 위해 20번포트로 클라이언트의 임의의 포트에게
# 데이터 연결 요청을 하기 때문에 클라이언트가 방화벽 설정이 되어 있을경우 데이터 교환이 되지 않음
ufw disable
# 액티브 모드로 접속확인
expect <<EOF
spawn ftp -n ${FTP_SERVER_IP}
expect "ftp>"
send "quote USER root\n"
send "quote PASS P@ssw0rd!\n"
send "ls\n"
send "put file01\n"
send "ls\n"
send "cd /etc\n"
send "get passwd\n"
send "quit\n"
expect eof
EOF
ufw enable
# 패시브 모드로 접속확인
expect <<EOF
spawn ftp -p -n ${FTP_SERVER_IP}
expect "ftp>"
send "quote USER root\n"
send "quote PASS P@ssw0rd!\n"
send "ls\n"
send "put file02\n"
send "ls\n"
send "cd /etc\n"
send "get shadow\n"
send "quit\n"
expect eof
EOF
'Operating Systems > Linux' 카테고리의 다른 글
[ Linux ] RAID 활용 ( 1 / 2 ) - CentOS7 (0) | 2021.10.18 |
---|---|
[ Linux ] SAMBA 서버 설치 (0) | 2021.10.16 |
[ Linux ] TFTP 서버 설치 (0) | 2021.10.15 |
[ Linux ] Quota 활용 (0) | 2021.10.02 |
[ Linux ] LVM 활용 (0) | 2021.10.01 |