Debian configuration FTP server

Debian configuration FTP server

1. Install FTP software

sudo atp-get install vsftpd

2. Configure the FTP configuration file

(1) First edit the configuration file /etc/vsftpd.conf

sudo vim /etc/vsftpd.conf		

(2) Add the following parameters at the end of the configuration file:

#禁止匿名用户登录和上传文件
anonymous_enable=NO
anon_mkdir_write_enable=NO
#允许本地用户登录
local_enable=YES
#允许上传文件
write_enable=YES
local_umask=022
#设置用户限制用户访问(写到/etc/vsftpd/vsftpd.chroot_list里的用户才可以拥有访问上层目录的权限)
#chroot_local_user=YES #默认为yes,当为no时,不写到/etc/vsftpd/vsftpd.chroot_list里的用户才有访问上层目录的权限)
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/vsftpd.chroot_list
#设置ftp用户访问进来的根目录
local_root=/mnt/data/ShareFolder
#在新的ftp版本中必须添加下面这行,不然普通用户无法通过ftp登录到设置的根目录
allow_writeable_chroot=YES	

3. Configure ordinary users (restricted users)

(1) Set ftp users to only log in with /sbin/nologin (considering the security issues caused by ssh login)

First open the /etc/shells file to see if there is a line of /sbin/nologin, if not, add it manually

(2) Add ftp common users

#这里设置ftp普通用户名为ftpuser,登陆执行的终端方式为/sbin/nologin,所属拥有权目录为/mnt/data/ShareFolder
sudo useradd -d /mnt/data/ShareFolder -s /sbin/nologin ftpuser
#设置用户密码
sudo passwd ftpuser
#设置ftp目录的用户权限
sudo chown ftpuser:ftpuser /mnt/data/ShareFolder

4. Add administrator user

(1) First create a chroot_list file

sudo mkdir /etc/vsftpd && sudo touch /etc/vsftpd/vsftpd.chroot_list

(2) After opening the /etc/vsftpd/vsftpd.chroot_list file, add the administrator user

#这里以该debian系统的管理员用户为user作示例,加入user的名字于/etc/vsftpd/vsftpd.chroot_list中
sudo vim /etc/vsftpd/vsftpd.chroot_list 
#添加user

5. Restart the vsftpd service

/etc/init.d/vsftpd restart
#接下来输入管理员密码,即完成重启

6. Login and use ftp

(1) Install ftp

sudo atp-get install ftp	

(2) Login to ftp

#输入登录的ip
ftp IP地址
#输入用户名
ftpuser
#输入密码

Guess you like

Origin blog.csdn.net/Anakin01/article/details/131224368