1. 程式人生 > >CentOS7下搭建FTP伺服器(轉載)

CentOS7下搭建FTP伺服器(轉載)

1、安裝vsftpd

首先檢視你是否安裝了vsftpd

[root@localhost ~]# rpm -q vsftpd
  • 1

vsftpd-3.0.2-10.el7.x86_64 (顯示也就安裝成功了!)

如果沒有則安裝vsftpd

[root@localhost ~]# yum install -y vsftpd
  • 1

安裝完成後可以檢視到安裝的目錄

[root@localhost ~]# whereis vsftpd
  • 1

vsftpd: /usr/sbin/vsftpd /etc/vsftpd /usr/share/man/man8/vsftpd.8.gz

檢視vsftpd服務的狀態

[root@localhost ~]# systemctl status vsftpd.service
  • 1

 vsftpd.service - Vsftpd ftp daemon 
 Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled) 
   Active: active (running) since 三 2017-07-05 14:29:53 CST; 3s ago 
Process: 3951 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS) 
 Main PID: 3953 (vsftpd) 
   CGroup: /system.slice/vsftpd.service 
├─3953 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf 
├─3963 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf 
└─3964 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf

7月 05 14:29:53 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon… 
7月 05 14:29:53 localhost.localdomain systemd[1]: Started Vsftpd ftp daemon.

開啟vsftpd服務

[root@localhost ~]# systemctl start vsftpd.service
  • 1

設定vsftpd服務開機自啟

[root@localhost ~]# systemctl enable vsftpd.service
(或者:[root@localhost ~]# chkconfig vsftpd on)
  • 1
  • 2

2、配置vsftpd.conf檔案

[[email protected] ~]# vi /etc/vsftpd/vsftpd.conf


# 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.
#xferlog_file=/var/log/xferlog
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
ascii_upload_enable=YES
ascii_download_enable=YES
#
# You may fully customise the login banner string:
ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES

pam_service_name=vsftpd
userlist_enable=YES
userlist_deny=NO
local_root=/var/public_root
tcp_wrappers=YES
use_localtime=YES
allow_writeable_chroot=YES

3、新增FTP賬戶

這裡設定的賬戶名為“test”,密碼為“123456”

[root@localhost ~]# useradd test -s /sbin/nologin
[root@localhost ~]# passwd 123456

4、編輯user_list檔案,允許test使用者訪問FTP

[[email protected] ~]# vi /etc/vsftpd/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
test
~                                                                                      
~                                                                                      
~                                                                                      
~                                                                                      
"/etc/vsftpd/user_list" 21L, 366C

5、建根目錄,並設定訪問許可權

[root@localhost ~]# mkdir /var/public_root
[root@localhost ~]# chown -R test /var/public_root
[root@localhost ~]# chmod -R 755 /var/public_root

6、防火牆設定

1.vi /etc/sysconfig/iptables

#編輯iptables檔案,新增如下內容,開啟21埠

-A INPUT -mstate --state NEW -m tcp -p tcp --dport 21 -j ACCEPT

2.如果系統啟用了防火牆和SELinux,那麼還要做以下配置(預設情況下CentOS7是使用firewall和selinux的,不在使用iptables)

防火牆新增FTP服務

[[email protected] ~]# firewall-cmd --permanent --zone=public --add-service=ftp
[[email protected] ~]# firewall-cmd --reload

設定SELinux

[root@localhost ~]# getsebool -a | grep ftp
[root@localhost ~]# setsebool -P ftpd_full_access on (tip:on可以替換為 1)

或者修改配置檔案徹底關閉selinux,需要重啟機器

[[email protected] ~]# vi /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=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted


~                                                                                      
~                                                                                      
~                                                                                      
~                                                                                      
~                                                                                      
~                                                                                      
~                                                                                      
~                                                                                      
~                                                                                      
~                                                                                      
"/etc/selinux/config" 14L, 546C

7、重啟vsftpd伺服器

[root@localhost ~]# systemctl stop vsftpd.service
[root@localhost ~]# systemctl start vsftpd.service
[root@localhost ~]# systemctl status vsftpd.service

解除安裝vsftpd的方法

如果配置出錯需要解除安裝vsftpd,在解除安裝之前先停止vsftpd

[root@localhost ~]# rpm -aq vsftpd

vsftpd-3.0.2-21.el7.x86_64 (此處是查詢vsftpd的返回結果)

用rpm -e 查詢結果 進行刪除就ok了

[root@localhost ~]# rpm -e vsftpd-3.0.2-21.el7.x86_64

warning: /etc/vsftpd/user_list saved as /etc/vsftpd/user_list.rpmsave 
warning: /etc/vsftpd/ftpusers saved as /etc/vsftpd/ftpusers.rpmsave   #刪除時將備份vsftp的使用者列表檔案

檢查是否解除安裝了vsftpd,進行stop及start操作

[root@localhost ~]# systemctl stop vsftpd.service

vsftpd: unrecognized service   #找不到vsftpd 

[root@localhost ~]# systemctl start vsftpd.service

vsftpd: unrecognized service   #找不到vsftpd

相關推薦

CentOS7搭建FTP伺服器轉載

1、安裝vsftpd首先檢視你是否安裝了vsftpd[root@localhost ~]# rpm -q vsftpd1vsftpd-3.0.2-10.el7.x86_64 (顯示也就安裝成功了!)如果沒有則安裝vsftpd[root@localhost ~]# yum in

Linux搭建FTP伺服器Ubuntu16.04

搞了下FTP伺服器,基本上能遇到的問題都遇到了-。-! 先說步驟: 1.安裝vsftpd軟體包 sudo apt-get install vsftpd 2.開啟配置檔案 vim /etc/vsftpd.conf 3.修改引數 一些引數可以去掉註釋啟用,為了方便,

Centos7安裝搭建FTP伺服器最簡便方法

  簡介: vsftpd 是“very secure FTP daemon”的縮寫,安全性是它的一個最大的特點。 vsftpd 是一個 UNIX 類作業系統上執行的伺服器的名字,它可以執行在諸如 Linux、BSD、Solaris、 HP-UNIX等系統上面,是一個完全免費的、開放原始碼的

CentOS搭建FTP伺服器

https://www.linuxidc.com/Linux/2017-11/148518.htm   本文測試環境  1、CentOS 7  2、測試伺服器IP 192.168.1.170 1、安裝並啟動 FTP 服務 1.1 安裝 VSFT

linux搭建郵件伺服器sendmail

一、Sendmail概述 sendmail是最重要的郵件傳輸代理程式。理解電子郵件的工作模式是非常重要的。一般情況下,我們把電子郵件程式分解成使用者代理,傳輸代理和投遞代理。使用者代理用來接受使用者的指令,將使用者的信件傳送至信件傳輸代理,如:outlook express

windows搭建Git伺服器

以下兩篇文章是在安裝Git伺服器時借鑑的文章,不錯,轉載在此: 1、所需的軟體下載及安裝 所需工具下載地址: 若只要使用git,只需要安裝msysgit就行了。copssh是一個ssh伺服器軟體。 msysgit的安裝: 我把安裝中關鍵的幾步截圖說明,其餘直接點

在Linux配置FTP伺服器心得

溫故知新。也不是第一次配置FTP了,之前第一次配置FTP的時候沒什麼阻礙,後來換了個電腦又配置了一次,搞了一個晚上都才配置完成。故特意寫這篇文章來提示下後人,也為了以後我忘了能回看怎麼配置。 進入正題!!! 在Linux下首先你得有網路。 測試網路

vmware的centos7搭建lnmp環境新手

學習了大概1周的Linux了,今天準備上網查一個搭建lnmp的教程在自己的虛擬機器上搭建環境。 1.安裝mysql 1.直接執行 [[email protected] ~]# yum install mariadb mariadb-server net-tool

Redhat7.0搭建郵件伺服器

前言:上次簡單的說明了郵件伺服器的工作原理以及簡單的配置郵件伺服器實現兩臺linux主機互相傳送郵件,這次再接著聊聊郵件伺服器。 概要: 1.Telnet 2.mutt 3.Thundbird 4.postfix+mysql+dovecot

Centos7 搭建ftp伺服器

一:安裝 首先檢視當前伺服器是否已經安裝vsftp。 [root@wst01 bbders]# rpm -q vsftpd package vsftpd is not installed (顯示沒有安裝) [root@wst01 bbde

Linux環境搭建Apache伺服器完整版

Linux下搭建Apache伺服器(完整版) 什麼是Apache? Apache Licence是著名的非盈利開源組織Apache採用的協議。該協議和BSD類似,同樣鼓勵程式碼共享和尊重原作者的著作權,同樣允許程式碼修改,再發布(作為開源或商業軟體)。需要

阿里雲伺服器購買配置、環境部署、搭建網站教程轉載

阿里雲伺服器購買怎麼選擇合適自己需求配置?如何安裝伺服器環境來搭建網站呢?很多沒有云計算基礎的小白在ecs伺服器配置上都會遇到各種問題,今天詳細的寫一篇阿里雲伺服器配置教程文章,手把手教導大家如何配置! 購買阿里雲伺服器或者其它任何產品,記得先領取阿里雲代金券

ubantu伺服器已有nginx的情況搭建rails環境passenger

因為我用的是root使用者所以就沒寫sudo!!! 第一步,安裝rvm和ruby apt-get install rvm 安裝到最後會出現以下提示: 意思大概是讓你新增使用者到rvm這個組,因為我用的是root使用者所以: adduser root rvm

Linux使用Rsyslog搭建中心日誌伺服器轉載

Syslog是一個通過IP網路允許一臺機器傳送事件通知資訊給事件收集者(Syslog伺服器或者Syslog Daemon)的協議。換言之,就是一臺機器或者裝置能夠被配置,使之產生Syslog資訊並且傳送到一臺特定的Syslog伺服器/Daemon。 Syslog資訊建立在UDP之上,一般S

CentOS7環境搭建ftp伺服器

檢視是否安裝ftp rpm -qa | grep vsftpd 安裝ftp yum -y install vsftpd 啟動 /bin/systemctl start vsftpd.service 重啟 /bin/systemctl rest

Ubuntu 14.04搭建SVN伺服器SVN Server

為了學習SVN伺服器是怎麼搭建的,我在Ubuntu虛擬機器上搭建了一個SVN伺服器,可以作為專案開發的版本,記錄下來防止自己遺忘,同時可以幫助更多的人。 一:搭建環境 檢視Ubuntu系統的版本資訊:可用cat /proc/version命令、uname -a命令與s

LinuxNFS服務器的搭建與配置轉載

nts 指定 ror 同步 5.x onu 說明 完整 發出 一、NFS服務簡介  NFS 就是 Network FileSystem 的縮寫,最早之前是由sun 這家公司所發展出來的。 它最大的功能就是可以透過網絡,讓不同的機器、不同的操作系統、可以彼此分享個別的檔案 (

centos7.2搭建FTP伺服器

搭建FTP伺服器 1、yum install vsftpd -y 2、啟動systemctl start vsftpd 3、檢視埠是否佔用 netstat -nltp | grep 21 4、訪問ftp://xxx.xxx.xxx.xxx即可 5、配置 FTP 許可權 瞭

在Windows Server 2008 R2搭建jsp環境-Tomcat的下載安裝

流行 ext 協議 解壓縮 需要 繼續 bsp shutdown 電腦系統 1.百度搜索“Tomcat官網”,點擊有標誌的官網進入,準備下載官方正版Tomcat。 2.進入Tomcat官網之後,在左邊我們看到,Tomcat的有6,7,8這三個最流行的版本,我們可以點

【linux】linux 環境 安裝禪道轉載 -- 跟web服務器無關,無視apache、nginx!!!

sdn php 修改 鏈接 net 壓縮 操作 tps 數據庫 參考文章 鏈接 :https://blog.csdn.net/xinxin19881112/article/details/46813991 講的非常完美、透徹,不像其他的文章,都是抄襲的,沒一點註意事項和自己