需求说明:

  今天项目中有一个新的需求,需要在linux环境中搭建一个ftp服务,在此记录下.

操作过程:

1.通过yum的方式安装ftp服务对应的软件包

[root@testvm01 ~]# yum install vsftpd
Loaded plugins: product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
rhel-source | 4.1 kB : ...
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 :2.2.-.el6_5. will be installed
--> Finished Dependency Resolution Dependencies Resolved ===============================================================================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================================================================
Installing:
vsftpd x86_64 2.2.-.el6_5. rhel-source k Transaction Summary
===============================================================================================================================================================================================
Install Package(s) Total download size: k
Installed size: k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : vsftpd-2.2.-.el6_5..x86_64 /
Verifying : vsftpd-2.2.-.el6_5..x86_64 / Installed:
vsftpd.x86_64 :2.2.-.el6_5. Complete!

备注:ftp对应的rpm包是:vsftpd.x86_64 0:2.2.2-12.el6_5.

2.启动ftp服务

[root@testvm01 ~]# ls /etc/init.d/vsftpd
/etc/init.d/vsftpd
[root@testvm01 ~]# service vsftpd start
Starting vsftpd for vsftpd: [ OK ]
[root@testvm01 ~]# ps -ef | grep vsftpd
root : ? :: /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
root : pts/ :: grep vsftpd

备注:通过以上的信息知道ftp对应的后台命令是vsftpd,对应的配置文件vsftpd.conf

3.设置ftp服务为开机自动启动

[root@testvm01 ~]# chkconfig --level  vsftpd on
[root@testvm01 ~]# chkconfig --list | grep vsftp
vsftpd :off :off :on :on :on :on :off

4.查看ftp服务监听的端口

[root@testvm01 ~]# netstat -ntlp | grep vsftpd
tcp 0.0.0.0: 0.0.0.0:* LISTEN /vsftpd

备注:ftp服务,默认监听的端口是21端口.

5.创建ftp用户,用于ftp登录

[root@testvm01 ~]# useradd ftpuser01
[root@testvm01 ~]# echo 'ftpuser01' | passwd --stdin ftpuser01
Changing password for user ftpuser01.
passwd: all authentication tokens updated successfully.
[root@testvm01 ~]# chage -M ftpuser01

6.在本地通过浏览器连接到ftp服务

备注:能够访问,但是并没有提示输入用户名和密码的信息.

7.限定只有某些用户能够访问ftp服务器

修改配置文件vsftpd.conf,增加以下内容

userlist_deny=NO

意思是说,只有在user_list文件中的用户可以登录.

将ftp用户加入到user_list这个文件中

[root@testvm01 vsftpd]# cat 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.
ftpuser01

8.重新通过浏览器进行访问

备注:此时,提示输入用户名和密码验证.

9.输入正确的用户名和密码之后,出现以下的错误

经过检查,系统打开了selinux,将其关闭.

10.查看selinux的状态

[root@testvm01 ~]# sestatus -b | grep ftp
allow_ftpd_anon_write off
allow_ftpd_full_access off
allow_ftpd_use_cifs off
allow_ftpd_use_nfs off
ftp_home_dir off
ftpd_connect_db off
ftpd_use_fusefs off
ftpd_use_passive_mode off
httpd_enable_ftp_server off
tftp_anon_write off
tftp_use_cifs off
tftp_use_nfs off

备注:也可以将selinux关闭掉.

11.将ftp_home_dir设置为on

[root@testvm01 ~]# setsebool -P ftp_home_dir on
[root@testvm01 ~]# sestatus -b | grep ftp_home_dir
ftp_home_dir on

12.重新进行ftp登录

备注:可以登录成功.至此ftp登录完成.

文档创建时间:2018年10月8日16:13:00

最新文章

  1. linux下select/poll/epoll机制的比较
  2. Mybatis
  3. 阿里云windows 2012服务器部署java web程序教程
  4. 【海岛帝国系列赛】No.4 海岛帝国:LYF的太空运输站
  5. (转)c & c++内存分配
  6. POJ1840: Eqs(hash问题)
  7. ARC 工作原理
  8. c++ stl algorithm: std::find, std::find_if
  9. HDU 4006 The kth great number AVL解
  10. IOS 固定定位底部input输入框,获取焦点时弹出的输入法键盘挡住input
  11. 一个.net专业户转Spring Boot V2.0开发的体会
  12. 使用Springboot + Gradle快速整合Mybatis-Plus
  13. Storm入门(十四)Trident API Overview
  14. git 分支管理记录
  15. leetcode — search-for-a-range
  16. Windows四大傻X功能——那些拖慢系统性能的罪魁祸首
  17. struts2使用拦截器完成登陆显示用户信息操作和Struts2的国际化
  18. web前端关于html转义符的常用js函数
  19. 【C#】解析C#程序集的加载和反射
  20. 8. mybatis实战教程(mybatis in action)之七:实现mybatis分页(源码下载)

热门文章

  1. TED Notes 1 (What leads to success)
  2. Shell脚本 Hello World
  3. C/C++-标准输入/输出重定向为文件输入/输出
  4. PCL几种采样方法
  5. IntelliJ: Maven projects need to be imported: Import Changes Enable Auto-Import
  6. LeetCode practice
  7. 自然语言交流系统 phxnet团队 创新实训 个人博客 (十一)
  8. Intel edison 智能硬件开发指南 基于YoctoProject
  9. 【6】JVM-内存分配与回收策略
  10. Android seLinux 设置