温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

linux如何检查vsftpd是否安装

发布时间:2022-04-15 17:20:51 来源:亿速云 阅读:548 作者:zzz 栏目:建站服务器

这篇文章主要讲解了“linux如何检查vsftpd是否安装”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“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 ,否则表示未安装

linux如何检查vsftpd是否安装

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

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

linux如何检查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 vsftpd
Loaded plugins: fastestmirror, security
Setting up Install Process
Determining fastest mirrors
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: mirror.bit.edu.cn
base | 3.7 kB 00:00
base/primary_db | 4.7 MB 00:01
extras | 3.4 kB 00:00
extras/primary_db | 29 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 1.4 MB 00:00
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:2.2.2-24.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================
Installing:
vsftpd x86_64 2.2.2-24.el6 base 156 k

Transaction Summary
=============================================================================================================================
Install 1 Package(s)

Total download size: 156 k
Installed size: 340 k
Downloading Packages:
vsftpd-2.2.2-24.el6.x86_64.rpm | 156 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : vsftpd-2.2.2-24.el6.x86_64 1/1
Verifying : vsftpd-2.2.2-24.el6.x86_64 1/1

Installed:
vsftpd.x86_64 0:2.2.2-24.el6

Complete!

安装成功,可以使用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 4
drwxr-xr-x. 2 root root 4096 May 11 2016 pub
[root@localhost ~]#

3.3 默认匿名用户

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

[root@localhost ~]# id ftp
uid=14(ftp) gid=50(ftp) groups=50(ftp)
[root@localhost ~]# cat /etc/passwd | grep ftp
ftp: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 start
Starting vsftpd for vsftpd: [ OK ]
[root@localhost ~]#

2、重启服务器

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

3、停止服务器

[root@localhost ~]# service vsftpd stop
Shutting 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 vsftpd
vsftpd 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 vsftpd
vsftpd 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 restart
Shutting down vsftpd: [ OK ]
Starting vsftpd for vsftpd: [ OK ]
[root@localhost ~]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
[root@localhost ~]#

感谢各位的阅读,以上就是“linux如何检查vsftpd是否安装”的内容了,经过本文的学习后,相信大家对linux如何检查vsftpd是否安装这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI