(1) sudo apt-get install vsftpd 로 vsftpd 를 설치
sudo apt-get install vsftpd
(2) vsftpd를 설치 후 FTPS 설정을 위해 vsftpd inactive 설정 후 상태 확인
sudo service vsftpd stop
sudo service vsftpd status
설치된 vsftpd의 conf파일을 하기 내용과 같이 수정
(1) jcm@raspberrypi:~ $ sudo vim /etc/vsftpd.conf
(2) write_enable 영역의 주석을 해제하고 YES로 변경
#Uncomment this to enable any form of FTP write command.
write_enable=YES
(3) connect_from_port_20 부분을 주석처리 (data 포트를 20번 포트로 사용하지 않기 위함)
#Make sure PORT transfer connections originate from port 20 (ftp-data).
#connect_from_port_20=YES
(4) vsftpd.conf 가장 아래쪽에 하기 내용과 같이 추가 및 저장 후 종료
#PASV FTP OPTION
user_sub_token=USER
tcp_wrapper=YES
hide_ids=YES
pasv_enable=YES
pasv_min_port=5570
pasv_max_port=5579
pasv_address=10.60.1.141
(5) 임의로 정한 iptables 방화벽 포트 열기
iptables -I(대문자 i) INPUT(해당 정보가 삽입됨) -p tcp(tcp, udp) —dport 5570:5579(포트범위시작:포트범위끝) -j ACCEPT
설명 : 닫혀있는 5570~5579 포트를 사용할 것이기 때문에 추후 정상적으로 잘 작동되는 것을 확인하기 위해서 열어두는게 좋다.
jcm@raspberrypi:~ $ sudo iptables -I INPUT -p tcp --dport 5570:5579 -j ACCEPT
(6) 추가된 포트 확인
jcm@raspberrypi:~ $ sudo iptables -nL
(7) vsftpd 시작
jcm@raspberrypi:~ $ sudo service vsftpd start
jcm@raspberrypi:~ $ service vsftpd status
(8) 패시브 확인
jcm@raspberrypi:~ $ netstat -antp
(9) ssl 인증서 만들기
jcm@raspberrypi:/etc/vsftpd/ssl $ sudo openssl req -x509 -days 3650
Generating a RSA private key
.................+++++
.....+++++
writing new private key to 'privkey.pem'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.-----
Country Name (2 letter code) [AU]:08
State or Province Name (full name) [Some-State]seoul
Locality Name (eg, city) []:gangnam
Organization Name (eg, company) [Internet Widgits Pty Ltd]:kmwtest
Organizational Unit Name (eg, section) []:oransystem
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:jcmoffice@naver.com
설명 :
Country Name : 이것은 두 자로 된 ISO 형식의 국가 코드입니다.
State or Province Name : 시 이름을 입력해야 합니다. 약어를 사용할 수 없습니다 ex) Seoul
Locality Name : city를 입력합니다. 시 입력란과 동일하게 약어를 사용할 수 없습니다. ex) Gangnam
Organization Name : 사업자 또는 소속되어 있는 조직이나 회사명을 영문으로 입력하시면 됩니다.
Organization Unit Name : 사업자 또는 소속되어 있는 조직이나 회사 내 부서명을 입력하면 됩니다. ex) system team, Software development team...
Common Name : 그밖의 적을만한 내용이 없으면 enter입력합니다.
Email Address : 본인의 이메일 주소를 입력합니다.
모든 ssl 입력이 끝나면 아래와 같이 암호화된 메세지들과 함께 인증서가 생성됩니다.
-----BEGIN CERTIFICATE-----
MIID1TCCAr2gAwIBAgIUaNwR6YfwJXgCXX4riS4KU0jn1+IwDQYJKoZIhvcNAQEL
BQAwejELMAkGA1UEBhMCMDgxDjAMBgNVBAgMBXNlb3VsMRAwDgYDVQQHDAdnYW5n
(10) vsftpd.conf설정 (sudo vi /etc/vsftpd.conf)
해당영역 주석 처리 후 ssl enable 설정
#This option specifies the location of the RSA certificate to use for SSL
#encrypted connections.
#rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
#rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=YES
맨아래 추가
#SSL OPTION
rsa_cert_file=/etc/vsftpd/ssl/privkeyjcm.pem
rsa_private_key_file=/etc/vsftpd/ssl/privkeyjcm.pem
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
#require_ssl_reues=NO
#ssl_ciphers=HIGH
vsftpd.conf 설정 마무리 후 sudo service vsftpd restart
(11) FTP 접속