centos7 配置ftp服務(wù)器

  1. 安裝
  yum -y install vsftpd
  1. 配置
  vim /etc/vsftpd/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=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=066
#
# 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
# 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
  1. 增加ftp用戶
[root@localhost ~]# useradd cent -s /sbin/nologin
[root@localhost ~]# passwd cent
  1. 編輯user_list以躯,允許cent用戶訪問(wèn)ftp
[root@localhost vsftpd]# vim 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
cent                     
  1. 建立我們的根目錄,并設(shè)置訪問(wèn)權(quán)限
[root@localhost ~]# mkdir /var/public_root
[root@localhost ~]# chown -R cent /var/public_root
[root@localhost ~]# chmod -R 755 /var/public_root
  1. 啟動(dòng)服務(wù)
[root@localhost ~]# service vsftpd start
         或者 systemctl status vsftpd.service
  1. 設(shè)置開(kāi)機(jī)起動(dòng)
[root@localhost var]# chkconfig vsftpd on
         或者 systemctl enable vsftpd.service
  1. 卸載vsftpd方法

如果服務(wù)器上安裝了vsftpd,配置出錯(cuò)需要卸載vsftpd

[root@localhost ~]# rpm -aq vsftpd
vsftpd-2.0.5-16.el5_5.1 #此處是查找vsftpd的返回結(jié)果
[root@localhost ~]# rpm -e vsftpd-2.0.5-16.el5_5.1
#用rpm -e 查找結(jié)果 進(jìn)行刪除就ok了。warning:
/etc/vsftpd/user_list saved as /etc/vsftpd/user_list.rpmsavewarning: 
/etc/vsftpd/ftpusers saved as /etc/vsftpd/ftpusers.rpmsave #刪除時(shí)將備份vsftp的用戶列表文件。

看下是否卸載了vsftpd造垛,進(jìn)行stop及start操作:

[root@localhost ~]# /sbin/serv*ice vsftpd stop
vsftpd: unrecognized service #找不到vsftpd
[root@localhost ~]# /sbin/service vsftpd start
vsftpd: unrecognized service #找不到vsftpd記住,在卸載vsftpd之前晰搀,先停止vsftpd五辽。
  1. 如果連不上可能是防火墻或者selinux的問(wèn)題,把這兩個(gè)關(guān)了試試外恕。
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末杆逗,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子鳞疲,更是在濱河造成了極大的恐慌髓迎,老刑警劉巖,帶你破解...
    沈念sama閱讀 212,884評(píng)論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件建丧,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡波势,警方通過(guò)查閱死者的電腦和手機(jī)翎朱,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,755評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門(mén),熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)尺铣,“玉大人拴曲,你說(shuō)我怎么就攤上這事×莘蓿” “怎么了澈灼?”我有些...
    開(kāi)封第一講書(shū)人閱讀 158,369評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我叁熔,道長(zhǎng)委乌,這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 56,799評(píng)論 1 285
  • 正文 為了忘掉前任荣回,我火速辦了婚禮遭贸,結(jié)果婚禮上救鲤,老公的妹妹穿的比我還像新娘盲链。我一直安慰自己,他們只是感情好辉哥,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,910評(píng)論 6 386
  • 文/花漫 我一把揭開(kāi)白布删铃。 她就那樣靜靜地躺著耳贬,像睡著了一般。 火紅的嫁衣襯著肌膚如雪猎唁。 梳的紋絲不亂的頭發(fā)上咒劲,一...
    開(kāi)封第一講書(shū)人閱讀 50,096評(píng)論 1 291
  • 那天,我揣著相機(jī)與錄音胖秒,去河邊找鬼缎患。 笑死,一個(gè)胖子當(dāng)著我的面吹牛阎肝,可吹牛的內(nèi)容都是我干的挤渔。 我是一名探鬼主播,決...
    沈念sama閱讀 39,159評(píng)論 3 411
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼风题,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼判导!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起沛硅,我...
    開(kāi)封第一講書(shū)人閱讀 37,917評(píng)論 0 268
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤眼刃,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后摇肌,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體擂红,經(jīng)...
    沈念sama閱讀 44,360評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,673評(píng)論 2 327
  • 正文 我和宋清朗相戀三年围小,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了昵骤。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,814評(píng)論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡肯适,死狀恐怖变秦,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情框舔,我是刑警寧澤蹦玫,帶...
    沈念sama閱讀 34,509評(píng)論 4 334
  • 正文 年R本政府宣布赎婚,位于F島的核電站,受9級(jí)特大地震影響樱溉,放射性物質(zhì)發(fā)生泄漏挣输。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,156評(píng)論 3 317
  • 文/蒙蒙 一饺窿、第九天 我趴在偏房一處隱蔽的房頂上張望歧焦。 院中可真熱鬧,春花似錦肚医、人聲如沸绢馍。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,882評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)舰涌。三九已至,卻和暖如春你稚,著一層夾襖步出監(jiān)牢的瞬間瓷耙,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 32,123評(píng)論 1 267
  • 我被黑心中介騙來(lái)泰國(guó)打工刁赖, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留搁痛,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 46,641評(píng)論 2 362
  • 正文 我出身青樓宇弛,卻偏偏與公主長(zhǎng)得像鸡典,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子枪芒,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,728評(píng)論 2 351

推薦閱讀更多精彩內(nèi)容