欢迎使用CSDN-markdown编辑器

来源:互联网 发布:oracle erp 知乎 编辑:程序博客网 时间:2024/06/10 16:40

Linux vsftp

本机环境为centos 6.6 安装选择的minimal模式。

  • 查询系统是否已安装了vsftpd
[root@localhost/]# rpm -qa | grep vsftpdvsftpd-2.0.5-16.1.1.AXS3代表已安装了vsftpd,若没有安装请参照XXX来安装vsftpd[root@localhost/]# service vsftpd start 如果vsftpd没有启动 则启动vsftpd服务starting vsftpd for vsftpd:         [OK]
  • vsftpd默认配置是已经打开匿名服务访问的。操作如下:
D:\>ftpftp> open 192.168.0.211 (linux主机的IP地址)连接到 192.168.0.211220 (vsFTPd 2.0.5)用户(192.168.0.211:(none)): anonymous331 Please specify the password.密码:230 Login successful.ftp>

禁用匿名登录

[root@localhost/]# cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak修改配置前先备份原配置文件 将anonymous_enable=YES 设置为NO [root@localhost/]# vi /etc/vsftpd/vsftpd.conf12 annonymous_enable=NO[root@localhost/]# service vsftpd restart 重启服务
D:\>ftpftp> open 192.168.0.211连接到 192.168.0.211220 (vsFTPd 2.0.5)用户(192.168.0.211:(none)): anonymous331 Please specify the password.密码:530 Login incorrect.登录失败。ftp>

登录失败,证明禁用匿名登录配置成功。

  • 创建一个系统用户来登录FTP
[root@localhost/]# useradd -s /sbin/nologin fftp默认新增加的用户还不能登录,需要修改一下密码。[root@localhost/]# passwd fftp  修改密码
D:\>ftpftp> open 192.168.0.211连接到 192.168.0.211220 (vsFTPd 2.0.5)用户(192.168.0.211:(none)): fftp331 Please specify the password.密码:230 Login successful.

登录成功,新建的系统用户直接就可以登录ftp。默认这些系统用户是没有设置锁定在自己家目录的。测试如下。

ftp> dir200 PORT command successful. Consider using PASV.150 Here comes the directory listing.drwxr-xr-x    3 513      513          4096 Apr 13 14:29 Desktop226 Directory send OK.ftp: 收到 65 字节,用时 0.0065000.00千字节/秒。ftp> cd ..250 Directory successfully changed.ftp> dir200 PORT command successful. Consider using PASV.150 Here comes the directory listing.drwx------    5 513      513          4096 Apr 13 14:29 fftpdrwx------    2 511      90           4096 Apr 12 14:04 haclusterdrwx------    6 512      512          4096 Apr 13 13:49 llk226 Directory send OK.ftp: 收到 190 字节,用时 0.00190.00千字节/秒。ftp>

可以看到系统用户默认是没有锁定在自己家目录的。那这样不安全。需要配置锁定目录。

[root@localhost/]# vi /etc/vsftpd/vsftpd.conf去掉前面#号chroot_list_enable=YESchroot_list_file=/etc/vsftpd/chroot_list  限制更多系统用户然后把所有用户加入/etc/vsftpd/chroot_list 即可[root@localhost/]# ls /etc/vsftpd/chroot_list 默认chroot_list文件是不存在的,需要我们手动建立ftpusers user_list vsftpd.conf vsftpd.conf.bak vsftpd_conf_migrate.sh[root@localhost/]# touch /etc/vsftpd/chroot_list[root@localhost/]# cut -d : -f 1 /etc/passwd>>/etc/vsftpd/chroot_list 把本地用户全加入到这个限制文件中[root@localhost/]# service vsftpd restart 重启服务
D:\>ftpftp> open 192.168.0.211连接到 192.168.0.211220 (vsFTPd 2.0.5)用户(192.168.0.211:(none)): fftp331 Please specify the password.密码:230 Login successful.ftp> dir200 PORT command successful. Consider using PASV.150 Here comes the directory listing.drwxr-xr-x    3 513      513          4096 Apr 13 14:29 Desktop226 Directory send OK.ftp: 收到 65 字节,用时 0.0065000.00千字节/秒。ftp> cd ..250 Directory successfully changed.ftp> dir200 PORT command successful. Consider using PASV.150 Here comes the directory listing.drwxr-xr-x    3 513      513          4096 Apr 13 14:29 Desktop226 Directory send OK.ftp: 收到 65 字节,用时 0.0065.00千字节/秒。ftp>

经测试发现用户已经被锁定在自己家目录里了。

  • 系统添加一个用户默认有ftp的登录权限,是不安全的。要一个个设置,有点繁琐。利用ftp用户策略解决这个问题。即user_list文件设置,只有user_list中存在的用户才能登录系统。
[root@localhost/]# vi /etc/vsftpd/vsftpd.conf在userlist_enable=YES文件后面添加userlist_deny=NOuserlist_file=/etc/vsftpd/user_list  [root@localhost/]# service vsftpd restart 重启服务
D:\>ftpftp> open 192.168.0.211连接到 192.168.0.211220 (vsFTPd 2.0.5)用户(192.168.0.211:(none)): fftp530 Permission denied.登录失败。ftp>

操作证明配置正确。因为用户fftp没有加入至user_list文件中。所以登录失败。

[root@localhost/]# vi /etc/vsftpd/user_list 将用户加至文件最后一行[root@localhost/]# service vsftpd restart 重启服务
D:\>ftpftp> open 192.168.0.211连接到 192.168.0.211220 (vsFTPd 2.0.5)用户(192.168.0.211:(none)): fftp331 Please specify the password.密码:230 Login successful.ftp>

登录成功。

  • 有时也想限制一用户不能登录ftp
[root@localhost/]# cat /etc/vsftpd/ftpusers  查看限制用户可以将限制用户加入。用fftp用户测试。[root@localhost/]# vi /etc/vsftpd/ftpusers  将fftp用户加入文件最后一行[root@localhost/]# service vsftpd restart 重启服务
D:\>ftpftp> open 192.168.0.211连接到 192.168.0.211220 (vsFTPd 2.0.5)用户(192.168.0.211:(none)): fftp331 Please specify the password.密码:530 Login incorrect.登录失败。ftp>

登录失败。证明限制用户已起作用。

0 0
原创粉丝点击