正在學習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
爲該用戶創建主目錄
(未完待續...)