vsftpd安装、启动及查错

第一步:下载vsftpd的RPM包

你可以从下面两个地方获得最新的vsftpd的RPM包 Redhat's rpm collection 或者 rpmfind.net.为了你的方便, 你也可以使用wget从本站下载vsftpd的rpm包到你的本地电脑.

vsftpd-3.0.3-8.fc26.i686.rpm(fedora 26)
下载地址http://www.rpmfind.net/linux/rpm2html/search.php?query=vsftpd

一但有了vsftpd的RPM包,你就可以安装它
rpm -Uvh vsftpd-3.0.3-8.fc26.i686.rpm
就这样. Vsftpd现在正式安装.

第二步:启动并在"standalone"模式下进行测试

复制代码

代码如下:


vi /etc/vsftpd/vsftpd.conf

添加下面一行, 或者查看文件确定存在下面一行:

复制代码

代码如下:


listen=YES

保存并退出.
现在来启动vsftpd...

代码如下:


/usr/sbin/vsftpd &

第三步:创建用户

命令:useradd ftpuser

指定密码:passwd ftpuser

此用户就是用来登录ftp服务器用的。

这样一个用户建完,可以用这个登录,记得用普通登录不要用匿名了。登录后默认的路径为 /home/ftpuser.

----------------------------------------------------------------------------------------------------------------------------------

设置FTP用户的账号,例如账号为“ftpuser1”,目录为/home/ftpuser1,且设置不允许通过ssh登录。

?

1

useradd -d /home/ftpuser -s /sbin/nologin ftpuser

设置账号对应的密码,例如密码为“ftpuser”

?

1

passwd ftpuser

 

 

第四步:登录服务器

现在来用ftp命令至你的服务器. 你可以看到如下面这下样的成功登陆后的会话信息:

复制代码

代码如下:


[root@somehost]ftp localhost
Connected to localhost.localdomain.
220 (vsFTPd 1.2.1)
Name (localhost:admin): bobsmith (很明显,你必须使用在你的服务器上的有效用户)
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
150 Here comes the directory listing.
-rw-r--r-- 1 1001 1001 25372 Jan 17 18:50 somefile.tar.gz
drwx------ 2 1001 1001 512 Jan 16 19:16 index.htm
226 Directory send OK.
ftp> quit
221 Goodbye.
[root@somehost]

 

第五步:vsftpd进程基本操作

在使用Vsftp服务是经常需要启动、停止、重启vsftp服务,下面是这几个操作使用的指令:

启动Vsftpd服务其命令为: service vsftpd start 或 /etc/init.d/vsftpd start

停止Vsftpd服务的命令为:service vsftpd stop 或 /etc/init.d/vsftpd stop

重新启动Vsftpd服务的命令为:service vsftpd restart 或 /etc/init.d/vsftpd restart

检查Vsftpd服务的运行状态:service vsftpd status

 

第六步:进程出错

以上问题请手动杀死一下vsftp的进程就可以启动了

查找进程号

ps -aux | grep vsftp

产生如下:

root  3549  0.0  0.0 112648   968 pts/0    R+   09:15  0:00 grep --color=auto vsftp

 杀死进程

kill 3549

重启服务

/bin/systemctl restart vsftpd.service

 

 

I had the same problem recently, I also got the message:
500 OOPS: failed to open xferlog log file:/var/log/xferlog

This is what I did:

Open a terminal
Switch to root using su -
service vsftpd stop
Wait for the message: Shutting down vsftpd: [ OK ]
After this I removed the log file
rm /var/log/vsftpd.log
Type "y" for the question: rm: remove regular file `/var/log/vsftpd.log'?
service vsftpd start

After I did this everything worked OK.
vsftpd created a new log file in /var/log/ and it logged every upload/download.
I hope this have helped you. 

 

 

查看命令:getsebool -a | grep ftp

?

1

2

3

4

5

6

7

8

9

getsebool -a | grep ftpd

#以下是显示出来的权限,off是关闭权限,on是打开权限

allow_ftpd_anon_write --> off

allow_ftpd_full_access --> off

allow_ftpd_use_cifs --> off

allow_ftpd_use_nfs --> off

ftpd_connect_db --> off

ftpd_use_passive_mode --> off

ftp_home_dir --> off

其中,ftp_home_dir和allow_ftpd_full_access必须为on 才能使vsftpd 具有访问ftp根目录,以及文件传输等权限。

      设置命令:setsebool -p xxxxxx on

?

1

2

[root@bogon ~]# setsebool -P allow_ftpd_full_access on

[root@bogon ~]# setsebool -P ftp_home_dir on

 

第七步:vsftpd.conf解释


下面是我的vsftpd.conf文件
# Example config file /etc/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.
#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  <-----ftp server 上文件的权限
#
# 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.
#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   <----切换目录时,显示目录下.message的内容
#
# Activate logging of uploads/downloads.
xferlog_enable=YES  <--------是否允许上传和下载时显示日志
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES    <-------FTP数据端口的数据连接
#
# 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   <-----改变上传文件的所有者为root
#chown_username=whoever    
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log    <----日志目录
#
# If you want, you can have your log file in standard ftpd xferlog format
#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   <---没有数据传输的话  2分钟断
#
# 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  <--------运行vsftpd需要的非特殊系统用户
#
# 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  <--------是否允许运行特殊的FTP命令async
#
# 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的上传传输
#ascii_download_enable=YES   <---------是否启用ASCII的下载传输
#
# 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().
#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   〈----- 是否允许使用“ls”命令
listen=YES
secure_chroot_dir=/usr/local/share/vsftpd/empty

理解了上面的配置选项  再配置起来就不复杂了
比如我要建立一个wang的用户有上传和下载的权限
编辑vsftpd.conf找到
#local_enable=YES
#write_enable=YES 把注释去掉 重起服务器
再建一个wang的用户  客户端就可以wang 用户登陆了
C:/>ftp 192.168.1.4
Connected to 192.168.1.4.
220 (vsFTPd 2.0.6)
User (192.168.1.4:(none)): wang
331 Please specify the password.
Password:
230 Login successful.
ftp> bin
200 Switching to Binary mode.
ftp> put lame.exe
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 File receive OK.
ftp: 发送 153088 字节,用时 0.02Seconds 9568.00Kbytes/sec.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
index
lame.exe
226 Directory send OK.
ftp: 收到 17 字节,用时 0.00Seconds 17000.00Kbytes/sec.
ftp> del lame.exe
250 Delete operation successful.

 

 

 

https://www.cnblogs.com/amanlikethis/archive/2013/12/08/3464010.html

转载于:https://www.cnblogs.com/umbrella-panda/articles/9121663.html

评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符 “速评一下”
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页