2.1 for ubuntu16
ftp 简介
FTP(File Transfer Protocol,文件传输协议) 是 TCP/IP 协议组中的协议之一。FTP协议包括两个组成部分,其一为FTP服务器,其二为FTP客户端。其中FTP服务器用来存储文件,用户可以使用FTP客户端通过FTP协议访问位于FTP服务器上的资源。在开发网站的时候,通常利用FTP协议把网页或程序传到Web服务器上。
此外,由于FTP传输效率非常高,在网络上传输大的文件时,一般也采用该协议。 默认情况下FTP协议使用TCP端口中的 20和21这两个端口,其中20用于传输数据,21用于传输控制信息。但是,是否使用20作为传输数据的端口与FTP使用的传输模式有关,如果采用主动模式,那么数据传输端口就是20;如果采用被动模式,则具体最终使用哪个端口要服务器端和客户端协商决定。
ftp可以很方便的在本地和服务器之间传递数据,当然对象存储也是不错的,自己开发的file服务器也是可以的
开始搭建 ftp
install
sudo apt install vsftpd
# anonymous_enable=Yes 禁止匿名登录,不用开启
change home directory
During installation a ftp user is created with a home directory of /srv/ftp. This is the default FTP directory. If you wish to change this location, to /srv/files/ftp for example, simply create a directory in another location and change the ftp user's home directory:
在ftp安装的时候,会自动创建一个ftp的用户,其根目录是/srv/ftp
如果你想改变默认目录,eg /srv/files/ftp
, 可以先创建这个目录,然后指定家目录, 建议不要改
sudo mkdir /srv/files/ftp
sudo usermod -d /srv/files/ftp ftp
After making the change restart vsftpd:
改完之后, 重启
sudo systemctl restart vsftpd.service
edit /etc/vsftpd.conf
:
# 增加写入权限 允许上传
write_enable=YES
securing ftp
There are options in /etc/vsftpd.conf to help make vsftpd more secure. For example users can be limited to their home directories by uncommenting:
chroot_local_user=YES
You can also limit a specific list of users to just their home directories:
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
After uncommenting the above options, create a /etc/vsftpd.chroot_list containing a list of users one per line. Then restart vsftpd:
sudo systemctl restart vsftpd.service
这时已经可以用ftp登录了,我用的是scott
使用域名登录
只需用DNS服务器对域名进行解析即可,这里用DNSPod
域名解析
ping一下
再用客户端登录一下
success!
使用 FTP+TLS/SSL 登录
在上面的基础上
ssl_enable=Yes
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
sudo systemctl restart vsftpd.service
ftp客户端
初次使用是需要序列号的,本人使用的是
user | CN |
Piratez Rule | FETCHED001-F1EP-490F-902E-M1R2-RE0M |