正在学习linux操作,下面是ftp服务器的安装使用过程中使用到的命令行命令:
下载安装ftp服务器:
yum install vsftpd -y
Loaded plugins: fastestmirror, langpacks
epel | 4.7 kB 00:00:00
extras | 3.4 kB 00:00:00
os | 3.6 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/7): epel/7/x86_64/group_gz | 84 kB 00:00:00
(2/7): epel/7/x86_64/updateinfo | 922 kB 00:00:00
(3/7): updates/7/x86_64/primary_db | 1.0 MB 00:00:00
(4/7): epel/7/x86_64/primary_db | 6.4 MB 00:00:00
(5/7): os/7/x86_64/group_gz | 166 kB 00:00:00
(6/7): extras/7/x86_64/primary_db | 125 kB 00:00:00
(7/7): os/7/x86_64/primary_db | 5.9 MB 00:00:00
Determining fastest mirrors
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:3.0.2-22.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================
Package Arch Version Repository Size
==================================================================================
Installing:vsftpd x86_64 3.0.2-22.el7 os 169 k
Transaction Summary
==================================================================================
Install 1 Package
Total download size: 169 k
Installed size: 348 k
Downloading packages:
vsftpd-3.0.2-22.el7.x86_64.rpm | 169 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : vsftpd-3.0.2-22.el7.x86_64 1/1
Verifying : vsftpd-3.0.2-22.el7.x86_64 1/1
Installed:
vsftpd.x86_64 0:3.0.2-22.el7
Complete!
系统会显示以上内容,这时ftp下载安装完成
运行命令后等待服务器执可,安装完成后运行一下命令:
启动ftp服务器:
service vsftpd start
由于我的服务器上已经有ftp在运行执行后shell提示:
Redirecting to /bin/systemctl start vsftpd.service
这时再运行
/bin/systemctl start vsftpd.service
这时命令运行成功.
ftp下载后是放在/etc/vsftpd/目录下的,配置文件都可以到这个目录下查看
权限设置修改是在这个目录下的vsfptd.conf文件中进行配置,使用vim打开vsftpd.conf:
# 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=YES
#
# 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
# obviously need to create a directory writable by the FTP user.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
-- INSERT --
ftpusers文件配置禁止访问ftp服务器的用户列表
使用cat 命令查看ftpusers
# Users that are not allowed to login via ftp
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
user_list文件用来配置用户访问控制
打开后:
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
设置以下权限:
# 禁用匿名用户
anonymous_enable=NO
# 禁止切换根目录
chroot_local_user=YES
编辑完成后执行重启的命令
service vsftpd restart
创建一个用户
useradd ftpuser
如果将来这个账户不需要使用了可以将其删除,删除前需要对文件进行备份
userdel -r ftpuser
设置密码
echo "password" | passwd ftpuser --stdin
设置该用户仅能通过ftp进行访问
usermod -s /sbin/nologin ftpuser
为该用户创建主目录
(未完待续...)