ubuntu安装vsftpd
1. 未学安装,先学卸载
apt remove --purge vsftpd
查看本地用户
root@santiagod-virtual-machine:~# tail -3 /etc/passwd santiagod:x:1000:1000:santiagod,,,:/home/santiagod:/bin/bash sshd:x:128:65534::/run/sshd:/usr/sbin/nologin mysql:x:129:136:MySQL Server,,,:/nonexistent:/bin/false
2. 装包
apt install-y vsftpd
3. 启动服务
systemctl start vsftpd
再次查看本地用户
root@santiagod-virtual-machine:~# tail -3 /etc/passwd sshd:x:128:65534::/run/sshd:/usr/sbin/nologin mysql:x:129:136:MySQL Server,,,:/nonexistent:/bin/false ftp:x:130:137:ftp daemon,,,:/srv/ftp:/usr/sbin/nologin
root@santiagod-virtual-machine:~# cat /etc/ftpusers # /etc/ftpusers: list of users disallowed FTP access. See ftpusers(5). root daemon bin sys sync games man lp mail news uucp nobody
4. 修改ftp目录(默认:/srv/ftp),其他配置不动,在文件末尾追加一下内容
root@santiagod-virtual-machine:~# tail -10 /etc/vsftpd.conf
utf8_filesystem=YES
#userlist_enable=YES
#userlist_deny=NO
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/vsftpd.chroot_list
local_root=/home/vftp
root@santiagod-virtual-machine:~# mkdir /etc/vsftpd/
root@santiagod-virtual-machine:~# echo vftp > /etc/vsftpd/vsftpd.chroot_list
然后修改/etc/pam.d/vsftpd
root@santiagod-virtual-machine:~# sed -i 's/shells/nologin/g' /etc/pam.d/vsftpd
创建登陆用户,并绑定登陆目录(用户在目录中拥有的权限,取决于登陆用户对于目录的权限属主、属组、其他人的权限)
root@santiagod-virtual-machine:~# useradd -m vftp -s /sbin/nologin
root@santiagod-virtual-machine:~# echo vftp:vftp |chpasswd #提示bad password,但不影响ftp的登陆使用 BAD PASSWORD: The password is shorter than 8 characters root@santiagod-virtual-machine:~# ftp 127.0.0.1 Connected to 127.0.0.1. 220 (vsFTPd 3.0.5) Name (127.0.0.1:root): vftp 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> exit 221 Goodbye.
不同于centos,在ubuntu上vsftpd安装完成后,直接给ftp用户设置密码后也是能访问的
root@santiagod-virtual-machine:~# echo ftp:Admin@123 |chpasswd root@santiagod-virtual-machine:~# ftp 127.0.0.1 Connected to 127.0.0.1. 220 (vsFTPd 3.0.5) Name (127.0.0.1:root): ftp 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 229 Entering Extended Passive Mode (|||39748|) 150 Here comes the directory listing. -rw-r--r-- 1 0 0 4 Jun 28 23:44 test01.txt 226 Directory send OK. ftp> exit 221 Goodbye. root@santiagod-virtual-machine:~# ll -d /srv/ftp drwxr-xr-x 2 root ftp 4096 6月 28 23:48 /srv/ftp/
root@santiagod-virtual-machine:~# grep ^ftp /etc/passwd
ftp:x:130:137:ftp daemon,,,:/srv/ftp:/usr/sbin/nologin