Ubuntu Server搭建FTP服务器(2) --本地用户FTP服务器架设

参考:ubuntu中文wiki百科,网址:wiki.ubuntu.org.cn

环境:Ubuntu 9.04 Server+VSFTPD 2.0.7

slmagicbox@ubuntu904server:~$ uname -a
Linux ubuntu904server 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:48:10 UTC 2009 i686 GNU/Linux

slmagicbox@ubuntu904server:~$ dpkg -l  | grep vsftpd
ii  vsftpd                                    2.0.7-0ubuntu1                    The Very Secure FTP Daemon

原始配置文件/etc/vsftpd.conf:

本配置文件为安装vsftpd后默认生成的,以“#”开头为注释项

 # Example config file /etc/vsftpd.conf
    listen=YES               #以standalone模式运行vsftpd
    #listen_ipv6=YES
    anonymous_enable=YES  #允许匿名用户访问
    #local_enable=YES
    #write_enable=YES
    #local_umask=022
    #anon_upload_enable=YES
    #anon_mkdir_write_enable=YES
    dirmessage_enable=YES    #当用户首次进入FTP服务器的目录时,显示该目录下的message消息,默认为.message文件,可以用message_file来定义
    xferlog_enable=YES #启用日志,默认路径/var/log/vsftpd.log
    connect_from_port_20=YES  #数据连接使用默认的ftp-data端口(20端口)
    #chown_uploads=YES
    #chown_username=whoever
    #xferlog_file=/var/log/vsftpd.log
    #xferlog_std_format=YES
    #idle_session_timeout=600
    #data_connection_timeout=120
    #nopriv_user=ftpsecure
    #async_abor_enable=YES
    #ascii_upload_enable=YES
    #ascii_download_enable=YES
    #ftpd_banner=Welcome to blah FTP service.
    #deny_email_enable=YES
    #banned_email_file=/etc/vsftpd.banned_emails

# chroot_list_enable below.
    #chroot_local_user=YES
    #chroot_list_enable=YES
    #chroot_list_file=/etc/vsftpd.chroot_list
    #ls_recurse_enable=YES

# Debian customization
    secure_chroot_dir=/var/run/vsftpd #忽略
    pam_service_name=vsftpd  #忽略
    rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem #忽略
    rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key #忽略

修改后功能:

1)不允许匿名,本地用户可上传
     anonymous_enable=NO  #注释掉的话,默认为允许
     anon_upload_enable=NO #anonymous_enable=YES时起作用,注释掉的话,默认为允许,前提是全局上传权限开启(write_enable=YES)
     anon_mkdir_write_enable=NO #anonymous_enable=YES时起作用,注释掉的话,默认为允许,前提是全局上传权限开启(write_enable=YES)

local_enable=YES
     write_enable=YES
     local_umask=022 #默认为077

功能验证:

1)匿名用户无法登录
2)本地用户登录成功,并可浏览整个文件系统,ftp权限由系统权限来控制
3)在本地用户主目录下上传一个文件,并且创建一个文件夹,观察两者权限。
     slmagicbox@ubuntu904server:~$ ls -l
           drwxr-xr-x 2 slmagicbox slmagicbox 4096 2009-05-11 16:43 test1 #文件夹权限为 777-022=744
           -rw-r--r-- 1 slmagicbox slmagicbox    0 2009-05-11 16:43 test2#文件权限为 666-022=644
4) 添加一个本地用户ftptest1,让其可以ftp登录
     slmagicbox@ubuntu904server:~$ sudo useradd ftptest1 -m #创建一个新的本地用户ftptest1,-m参数为创建该用户home文件夹(/home/ftptest1),ftp用户必须有home目录,否则会报500 OOPS: cannot change directory:/home/ftptest1 的错误
     slmagicbox@ubuntu904server:/home$ sudo passwd ftptest1  #为ftptest1用户设置密码
     输入新的 UNIX 口令:
     重新输入新的 UNIX 口令:
     passwd: password updated successfully
    slmagicbox@XXX:~$ ftp 192.168.0.111
       Connected to 192.168.0.111.
       220 (vsFTPd 2.0.7)
       Name (192.168.0.111:slmagicbox): ftptest1
       331 Please specify the password.
       Password:
       230 Login successful.
       Remote system type is UNIX.
       Using binary mode to transfer files.
       ftp>      #登录成功
5)现在本地用户可以ftp了,但是让一个ftp用户在你的服务器上到处逛,是不是感觉不放心呢?是否可以将ftp用户限定在他们的home目录下呢?这就要用到ch_root功能了。
     编辑配置文件/etc/vsftpd.conf:
     chroot_local_user=YES

slmagicbox@ubuntu904server:~$ sudo /etc/init.d/vsftpd restart #重启一下服务,让配置更新

slmagicbox@FY-IT-Wangzh:~$ ftp 192.168.0.111
        Connected to 192.168.0.111.
        220 (vsFTPd 2.0.7)
        Name (192.168.0.111:slmagicbox): ftptest1
        331 Please specify the password.
        Password:
        230 Login successful.
        Remote system type is UNIX.
        Using binary mode to transfer files.
        ftp> ls
        200 PORT command successful. Consider using PASV.
        150 Here comes the directory listing.
        226 Directory send OK.
        ftp> cd /home
        550 Failed to change directory.  #用户被限定在自己的目录下活动了

6)上面的效果是不是你想要的呢,但是管理员自己能不能有个特权呢,可以不被限制在home目录下呢?
       编辑配置文件/etc/vsftpd.conf:
       chroot_local_user=YES
       chroot_list_enable=YES   #启用chroot_list,列在该文件里的用户排除在外,不限制在个人目录下
       chroot_list_file=/etc/vsftpd.chroot_list  #定义chroot_list文件位置

创建并编辑/etc/vsftpd.chroot_list:
       slmagicbox@ubuntu904server:/etc$echo "slmagicbox" | sudo tee -a vsftpd.chroot_list #把你希望排除在外的用户加入/etc/vsftpd.chroot_list
      
       slmagicbox@ubuntu904server:~$ sudo /etc/init.d/vsftpd restart
7)  仅靠local_enable=YES来控制本地用户可以访问ftp,使得服务器上的所有用户都有权限来访问ftp。你是不是希望可以控制,哪些用户可以访问,哪些用户不可访问?让我们继续 
       编辑配置文件/etc/vsftpd.conf:
          userlist_enable=YES   #启用ftp用户列表
          userlist_deny=NO     #不采用deny用户列表方式。userlist_deny可以理解为在userlist_file中列出的用户是被deny掉的,不允许访问ftp的,这里设置为NO,即表示该列表中的用户不是被deny掉的,是有权限访问ftp的。可能有点搞,简单点的理解就是userlist_deny设置是否采用黑名单,YES为采用;NO为不采用黑名单,即采用白名单。这里采用白名单,只有在userlist_file中列出的用户才有权访问ftp.
          userlist_file=/etc/vsftpd.user_list   #定义userlist_file文件存放位置    
       创建并编辑/etc/vsftpd.user_list:
          slmagicbox@ubuntu904server:~$ cd /etc/
          slmagicbox@ubuntu904server:/etc$ sudo touch vsftpd.user_list
          slmagicbox@ubuntu904server:/etc$ echo "slmagicbox" |sudo tee -a vsftpd.user_list
          slmagicbox@ubuntu904server:~$ sudo /etc/init.d/vsftpd restart
      看一下效果吧,应该只有slmagicbox可以访问ftp。之后,把需要访问ftp的用户加入/etc/vsftpd.user_list就行了,这样控制就简单了,不遵守纪律的,管理员随时可以把你请出去,别想用上ftp,嚯嚯!!

转载于:https://blog.51cto.com/slmagicbox/157156

Ubuntu Server搭建FTP服务器(2) --本地用户FTP服务器架设相关推荐

  1. linux ftp 团队认证,linux下ftp和ftps以及ftp基于mysql虚拟用户认证服务器的搭建

    linux下ftp和ftps以及ftp基于mysql虚拟用户认证服务器的搭建 1.FTP协议:有命令和数据连接两种 命令连接,控制连接:21/tcp 数据连接: 主动模式,运行在20/tcp端口 和 ...

  2. linux ftp mysql_linux下ftp和ftps以及ftp基于mysql虚拟用户认证服务器的搭建

    命令连接,控制连接:21/tcp 数据连接: 主动模式,运行在20/tcp端口 和 被动模式,运行在随机端口 数据传输模式(自动模式):有二进制(mp3,jpg等)和文本(html)两种传输模式 ft ...

  3. linux服务器定时关机重启,Ubuntu Server 10.10 每天定时开关机linux服务器应用 -电脑资料...

    Ubuntu Server 10.10定时开机方法: 按F2进入BIOS设置,设置每天定时开机, 容易出现问题: BIOS时间比系统时间慢8小时.在BIOS设置中设置时间或在Ubuntu系统中设置BI ...

  4. linux配置sftp-server,Ubuntu Server如何配置SFTP(建立用户监狱)

    SSH File Transfer Protocol是一个比普通FTP更为安全的文件传输协议.(参考资料:http://en.wikipedia.org/wiki/SSH_File_Transfer_ ...

  5. linux用户ftp失败,vsftpd本地用户登录密码错误的解决方法

    今天发现自己虚拟机的vsftp使用本地用户名无法登陆,于是重新配置,但配置了很多次都没成功,一直显示 530 Login incorrect. Login failed 解决方式是将vsftp.con ...

  6. 本地 服务器 共享文件,本地和云服务器文件共享

    本地和云服务器文件共享 内容精选 换一换 内网环境下,Windows云服务器之间怎样实现文件夹共享?部分运营商可能会屏蔽139.445端口,导致广域网无法访问共享.因此,Windows云服务器文件共享 ...

  7. 服务器远程显示用户忙,服务器远程显示用户忙

    服务器远程显示用户忙 内容精选 换一换 如果普通远程连接软件(如PuTTY)无法使用,您可以通过管理控制台的"远程登录"连接裸金属服务器实例,查看服务器操作界面.仅Linux操作系 ...

  8. 网站云服务器资料本地备份,云服务器上备份本地数据

    云服务器上备份本地数据 内容精选 换一换 云服务器备份(CSBS,Cloud Server Backup Service)提供对弹性云服务器(Elastic Cloud Server)和裸金属服务器( ...

  9. 2008域控服务器创建本地用户,[转载](一)安装win2008r2、域控、IIS、证书服务器、部署exchang...

    目的是最后完成exchange2010的部署,按照win2008r2---域控---IIS---证书服务器---证书认证---部署exchange2010---后续设置的步骤执行. 部署过程使用2g内 ...

最新文章

  1. linux 内核 同步机制
  2. Spring官网阅读(二)(依赖注入及方法注入)
  3. win上mysql忘记root密码_MySQL数据库之windows下mysql忘记root密码的解决方法
  4. python自动生成分析报告_利用PYTHON全自动生成分析报告
  5. java基础---多线程同步锁问题
  6. 前端学习(2256)如何解决冲突
  7. TensorFlow报错run() got multiple values for argument 'feed_dict'
  8. 【算法分析与设计】数组循环移位问题
  9. thinkphp实现当前页面点击下载文件实例
  10. 2020 大厂研发岗薪酬排名出炉,看完我真的拖后腿了。。。
  11. 【Flink】Flink 1.12.2 SlotManager
  12. [转]老婆还是自己好
  13. OpnCV_(HoughCircles to find circles)霍夫变换检测圆形
  14. Expression Blend实例中文教程(5) - 布局控件快速入门StackPanel,ScrollViewer和Border
  15. Ubuntu 编译最新LLVM套件:LLVM 16.0
  16. js中Object.defineProperty()方法的解释
  17. HC-05主从模式蓝牙配对说明v1.0
  18. 笔记本重装windows系统,office全家桶消失的解决方案
  19. Mac下制作Linux Centos7启动盘
  20. matlab如何镜像处理图片,matlab实现图像镜像

热门文章

  1. SAS 中计算总和或者计算总数的方法
  2. 使用MyBatis Generator自动生成实体、mapper和dao层
  3. 【洛谷P1538】迎春舞会之数字舞蹈
  4. 第一次ScrumMeeting博客:团队任务分解
  5. eclipse+pydev添加已存在django项目及其调试方法
  6. windows2003服务器版不能播放声音
  7. p4.pm p4python p4perl p4api 的使用方法
  8. CG-CTF-Web-AAencode
  9. 谈谈我对js中闭包的理解
  10. 了解冒泡排序选择排序