linux怎么检查vsftpd是否安装

linux检查vsftpd是否安装的方法:1、执行“rpm -qa | grep vsftpd”命令,如果输出vsftpd的相关信息则表示已经安装,否则没有安装;2、执行“vsftpd -v”命令,如果输出vsftpd的版本信息则表示安装。

本教程操作环境:CentOS 6系统、Dell G3电脑。

检测是否安装了vsftpd

方法1:使用rpm -qa | grep vsftpd命令来检测

如果有输出vsftpd 的相关信息, 则表示已经安装了vsftpd ,否则表示未安装

方法2:使用vsftpd -v命令通过查看安装版本来检测

如果输出vsftpd的版本信息则表示安装,否则表示未安装

如果没有安装vsftpd,可利用yum来安装

由于vsftpd 软件依赖一些其他的软件和软件库, 所以采用yum 方式安装比较容易

1、配置yum 源

联网: 联网情况下,不需要其它配置

不能联网: 可以配置本地yum源,可将Centos 系统盘,配置为u pan yum

2、安装vsftpd

对于使用yum 方式安装软件,通常需要使用root 用户才能安装,安装命令: yum -y install vsftpd

[root@localhost ~]# yum -y install vsftpdLoaded plugins: fastestmirror, securitySetting up Install ProcessDetermining fastest mirrors* base: centos.ustc.edu.cn* extras: centos.ustc.edu.cn* updates: mirror.bit.edu.cnbase | 3.7 kB 00:00base/primary_db | 4.7 MB 00:01extras | 3.4 kB 00:00extras/primary_db | 29 kB 00:00updates | 3.4 kB 00:00updates/primary_db | 1.4 MB 00:00Resolving Dependencies--> Running transaction check---> Package vsftpd.x86_64 0:2.2.2-24.el6 will be installed--> Finished Dependency ResolutionDependencies Resolved=============================================================================================================================Package Arch Version Repository Size=============================================================================================================================Installing:vsftpd x86_64 2.2.2-24.el6 base 156 kTransaction Summary=============================================================================================================================Install 1 Package(s)Total download size: 156 kInstalled size: 340 kDownloading Packages:vsftpd-2.2.2-24.el6.x86_64.rpm | 156 kB 00:00Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionInstalling : vsftpd-2.2.2-24.el6.x86_64 1/1Verifying : vsftpd-2.2.2-24.el6.x86_64 1/1Installed:vsftpd.x86_64 0:2.2.2-24.el6Complete!

安装成功,可以使用sftpd -v命令查看一下版本

3、默认配置

3.1 配置文件位置

vsftpd 服务配置文件默认在/etc/vsftp 目录下, 核心配置文件为vsftpd.conf.

[root@localhost ~]# ll /etc/vsftpd/total 28-rw-------. 1 root root 125 May 11 2016 ftpusers-rw-------. 1 root root 361 May 11 2016 user_list-rw-------. 1 root root 4599 May 11 2016 vsftpd.conf-rwxr--r--. 1 root root 338 May 11 2016 vsftpd_conf_migrate.sh-rw-------. 1 root root 4647 Jun 20 20:07 vsftpd.conf.rpmsave[root@localhost ~]#

3.2 默认根目录

vsftp 服务默认根目录为/var/ftp, 此目录所属者和所属组都是root.

[root@localhost ~]# ll -d /var/ftp/drwxr-xr-x. 3 root root 4096 Jul 1 16:58 /var/ftp/[root@localhost ~]# ll /var/ftp/total 4drwxr-xr-x. 2 root root 4096 May 11 2016 pub[root@localhost ~]#

3.3 默认匿名用户

vsftpd 安装过程中会创建ftp 用户作为匿名用户的代理用户,ftp 用户不能登录系统.

[root@localhost ~]# id ftpuid=14(ftp) gid=50(ftp) groups=50(ftp)[root@localhost ~]# cat /etc/passwd | grep ftpftp:x:14:50:FTP User:/var/ftp:/sbin/nologin[root@localhost ~]#

3.4 默认权限

默认配置下, vsftpd 服务允许匿名用户访问, 使用Linux 系统用户作为用户源, 允许系统用户登录.

匿名用户权限: 根目录/var/ftp, 可读, 可下载, 不可上传文件, 不可新建文件夹, 不可删除/更名文件

系统用户权限: 根目录为用户家目录,可跳出用户家目录, 对文件的权限由linux用户权限控制.

系统配置

安装vsftpd 之后, 需要对系统做一些修改配置

ftp_home_dir: 解决非root 用户登录报错: OOPS: child died

allow_ftpd_full_access: 解决不能上传文件问题

selinux: 解决不能登录OOPS: priv_sock_get_cmd

[root@localhost vsftpd] setsebool -P ftp_home_dir on[root@localhost vsftpd] setsebool allow_ftpd_full_access on[root@localhost vsftpd]# vim /etc/selinux/config# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - No SELinux policy is loaded.SELINUX=permissive# SELINUXTYPE= can take one of these two values:# targeted - Targeted processes are protected,# mls - Multi Level Security protection.SELINUXTYPE=targeted

服务器启动

Centos 系列可通过service 命令进行服务器的启动, 停止, 重启

1、启动服务器

[root@localhost ~]# service vsftpd startStarting vsftpd for vsftpd: [ OK ][root@localhost ~]#

2、重启服务器

[root@localhost ~]# service vsftpd restartShutting down vsftpd: [ OK ]Starting vsftpd for vsftpd: [ OK ][root@localhost ~]#

3、停止服务器

[root@localhost ~]# service vsftpd stopShutting down vsftpd: [ OK ][root@localhost ~]#

4、设置开机自启

可以选择将vsftpd服务设置为开机自启, 设置方式可以使用chkconfig 命令, 也可以自定义启动脚本.笔者使用chkconfig 命令. chkconfig 可以对linux 的其中运行级别分别设置开机启动.

0:表示关机1:单用户模式2:无网络连接的多用户命令行模式3:有网络连接的多用户命令行模式4:不可用5:带图形界面的多用户模式6:重新启动

4.1 查看vsftpd 服务开机启动状态

[root@localhost ~]# chkconfig | grep vsftpdvsftpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off[root@localhost ~]#

4.2 修改vsftpd 开机启动

我们只设置开机级别为35 的时候,自动启动vsftpd 服务即可.

[root@localhost ~]# chkconfig --level 35 vsftpd on[root@localhost ~]# chkconfig | grep vsftpdvsftpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off[root@localhost ~]#

vsftpd 防火墙设置

vsftpd服务默认监听20和21端口, 其它电脑要想访问,那么需要释放防火墙端口或关闭防火墙.不推荐关闭防火墙方式.vsftpd 传输数据默认使用PASV安全模式,所以需要设置PASV端口上下限,并释放端口

1、设定PASV 端口上下限

编辑配置文件: /etc/vsftpd/vsftpd.conf, 文件末尾追加两行:

#设定PASV 端口下限pasv_min_port=61000#设定PASV 端口上限pasv_max_port=62000

2、释放防火墙端口

编辑配置文件: /etc/sysconfig/iptables, 文件中添加以下配置:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 20 -j ACCEPT-A OUTPUT -m state --state NEW -m tcp -p tcp --dport 20 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT-A OUTPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 61000:62000 -j ACCEPT-A OUTPUT -m state --state NEW -m tcp -p tcp --dport 61000:62000 -j ACCEPT

3、重启服务

重启vsftpd服务和防火墙

[root@localhost ~]# service vsftpd restartShutting down vsftpd: [ OK ]Starting vsftpd for vsftpd: [ OK ][root@localhost ~]# service iptables restartiptables: Setting chains to policy ACCEPT: filter [ OK ]iptables: Flushing firewall rules: [ OK ]iptables: Unloading modules: [ OK ]iptables: Applying firewall rules: [ OK ][root@localhost ~]#

相关推荐:《Linux视频教程》

以上就是linux怎么检查vsftpd是否安装的详细内容,更多请关注其它相关文章!

因害怕失败而不敢放手一搏,永远不会成功

linux怎么检查vsftpd是否安装

相关文章:

你感兴趣的文章:

标签云: