[root@localhost ~]# yum install -y vsftpd
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
There are no enabled repos.
Run "yum repolist all" to see the repos you have.
To enable Red Hat Subscription Management repositories:
subscription-manager repos --enable <repo>
To enable custom repositories:
yum-config-manager --enable <repo>
此系统未向授权服务器注册。您可以使用订阅管理器进行注册。
查看当前RHEL的订阅状态
[root@localhost ~]# subscription-manager list
+-------------------------------------------+
安装的产品状态
+-------------------------------------------+
产品名称: Red Hat Enterprise Linux Server
产品 ID: 69
版本: 7.9
构架: x86_64
状态: 未知的
状态详情:
开始:
结束:
使用下述命令注册系统后,自动关联匹配系统的可用订阅:
[root@localhost ~]# subscription-manager register --username=admin --password=zhao123456. --auto-attach
正在注册到:subscription.rhsm.redhat.com:443/subscription
HTTP error (401 - Unauthorized): Service not available, please try again later
HTTP错误(401-未授权):服务不可用,请稍后再试
解决办法:
登陆开发者社区后,访问:
https://access.redhat.com/management/activation_keys
即可查询到自己的org id。
通过新建一个订阅,创建activation key
subscription-manager register --org=ORG ID --activationkey= Key Name
步骤1:安装FTP服务。
[root@localhost ~]# yum install -y vsftpd
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
rhel-7-server-rpms | 3.5 kB 00:00:00
(1/3): rhel-7-server-rpms/7Server/x86_64/group | 631 kB 00:00:04
(2/3): rhel-7-server-rpms/7Server/x86_64/updateinfo | 3.9 MB 00:00:04
(3/3): rhel-7-server-rpms/7Server/x86_64/primary_db | 77 MB 00:00:15
正在解决依赖关系
--> 正在检查事务
---> 软件包 vsftpd.x86_64.0.3.0.2-28.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
=========================================================================================================
Package 架构 版本 源 大小
=========================================================================================================
正在安装:
vsftpd x86_64 3.0.2-28.el7 rhel-7-server-rpms 172 k
事务概要
=========================================================================================================
安装 1 软件包
总下载量:172 k
安装大小:353 k
Downloading packages:
警告:/var/cache/yum/x86_64/7Server/rhel-7-server-rpms/packages/vsftpd-3.0.2-28.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
vsftpd-3.0.2-28.el7.x86_64.rpm 的公钥尚未安装
vsftpd-3.0.2-28.el7.x86_64.rpm | 172 kB 00:00:09
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release 检索密钥
导入 GPG key 0xFD431D51:
用户ID : "Red Hat, Inc. (release key 2) "
指纹 : 567e 347a d004 4ade 55ba 8a5f 199e 2f91 fd43 1d51
软件包 : redhat-release-server-7.9-3.el7.x86_64 (@anaconda/7.9)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
导入 GPG key 0x2FA658E0:
用户ID : "Red Hat, Inc. (auxiliary key) "
指纹 : 43a6 e49c 4a38 f4be 9abf 2a53 4568 9c88 2fa6 58e0
软件包 : redhat-release-server-7.9-3.el7.x86_64 (@anaconda/7.9)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : vsftpd-3.0.2-28.el7.x86_64 1/1
验证中 : vsftpd-3.0.2-28.el7.x86_64 1/1
rhel-7-server-rpms/7Server/x86_64/productid | 2.1 kB 00:00:00
已安装:
vsftpd.x86_64 0:3.0.2-28.el7
完毕!
步骤2:设置不允许匿名用户登录
修改/etc/vsftpd/vsftpd.conf文件,将anonymous_enable选项设置为NO。
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
# When SELinux is enforcing check for SE bool ftp_home_dir
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
步骤3:设置将所有本地用户都锁定在家目录中。
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
chroot_local_user=YES # 将该行前的#号去掉,并设置为YES
chroot_list_enable=NO # 将该行前的#号去掉,并设置为NO
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
xferlog_file=/var/log/vsftpd.log
[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
idle_session_timeout=300 # 将该行前的#号去掉,设置为300秒
data_connection_timeout=600 # 将该行前的#号去掉,设置为600秒
# 添加以下内容
max_clients=5000 # 设置FTP服务器允许的最大连接数为5000
max_per_ip=15 # 设置每个IP地址最大连接数为15
local_max_rate=512000 # 限制本地用户最大传输速度为512Kb/s
步骤6:启动FTP服务。
service vsftpd start
老版本启动命令可能会报错
systemctl start vsftpd
新版本命令
[root@localhost ~]# service vsftpd start
Redirecting to /bin/systemctl start vsftpd.service
Redirecting to /bin/systemctl start vsftpd.service
重定向到/bin/systemctl startvsftpd.服务
步骤7:创建FTP本地用户
[root@localhost ~]# useradd -d /var/ftp/dabo/ dabo -s /sbin/nologin
[root@localhost ~]# passwd zhao123456.
步骤8:测试FTP服务。
在一台使用Windows 7操作系统的PC机上,访问ftp://ftp.text.com,将会弹出用户登录对话框,如图所示。输入正确的用户名和密码登录后,即可使用FTP服务进行文件传输了。同时表明该服务器不允许匿名登录。