在Ubuntu系统上搭建Ftp服务器(保姆级教程) |
您所在的位置:网站首页 › ftp如何搭建服务器 › 在Ubuntu系统上搭建Ftp服务器(保姆级教程) |
在Ubuntu系统上搭建Ftp服务器(保姆级教程)
嘻嘻发布于2023-03-23
最后更新于2023年3月23日
51
浏览
文章目录 1 创建FTP用户2 安装vsftpd服务器3 配置vsftpd.conf文件3.1 配置用户3.2 配置ftp上传/下载文件的存放目录4 服务重启,配置生效5 本地登录验证6 常见问题FTP(File Transfer Protocol)是一种文件传输协议,可以用于在计算机之间进行文件传输。安装FTP服务器可以让你轻松地在多台设备间进行文件传输,在工作很多场景中都会用到,那如何在Ubuntu系统上搭建Ftp服务器呢? 创建FTP用户 useradd -m -d /home/ftp ftp_user 安装vsftpd服务器 sudo apt-get update sudo apt-get install vsftpd 配置vsftpd.conf文件配置文件:sudo vi /etc/vsftpd.conf # Allow anonymous FTP? (Disabled by default). #是否允许匿名登录,一般不允许 anonymous_enable=NO #是否允许本机用户登录 local_enable=YES # # Uncomment this to enable any form of FTP write command. #允许上传文件到ftp服务器 write_enable=YES # 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 userlist_enable=YES userlist_deny=NO userlist_file=/etc/vsftpd/user_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 #utf8_filesystem=YES #配置ftp服务器的上传下载文件所在的目录。 local_root=/home/ftp 配置用户新建 /etc/vsftpd.chroot_list 文件,在里面添加登录ftp服务器的linux用户 sudo vi /etc/vsftpd.chroot_listvsftpd.chroot_list文件内容,jack是我linux的用户名: jack 配置ftp上传/下载文件的存放目录这个目录要和vsftpd.conf中配置路径一致,比如上面配置的是local_root=/home/ftp,就新建/home/ftp目录 服务重启,配置生效 sudo /etc/init.d/vsftpd restart 本地登录验证ftp服务配置完成后,可以现在本地登录验证ftp 127.0.0.1 1、禁止FTP用户登录ssh, 但是能正常登录FTP #不允许ftp用户ssh登录 #打开/etc/shells,添加“/usr/bin/nologin”,即可 usermod -s /usr/bin/nologin username #允许ftp用户ssh登录 usermod -s /bin/bash username2、服务器修改ftp默认21端口 vim /etc/vsftpd.conf # 尾部新增下面这一行 #listen_port=8021 # 重启服务 /etc/init.d/vsftpd restart # 查看新监听的端口 netstat -utlpn | grep vsftp3、限制用户只能访问主目录 $ vim /etc/vsftpd/chroot_list # 这里可以填入用户,如 user1。 # 如果不填 user1,那么 user1 登录后直接访问到的目录是 /home/ftp,并且不能访问上一级 # 如果填了 user1,那么 user1 可以访问上一级 # 但不管填不填,都需要有这个文件 # 通过搭配能实现以下几种效果: # ① 当chroot_list_enable=YES,chroot_local_user=YES时,在/etc/vsftpd.chroot_list文件中列出的用户,可以切换到其他目录;未在文件中列出的用户,不能切换到其他目录。 # ② 当chroot_list_enable=YES,chroot_local_user=NO时,在/etc/vsftpd.chroot_list文件中列出的用户,不能切换到其他目录;未在文件中列出的用户,可以切换到其他目录。 # ③ 当chroot_list_enable=NO,chroot_local_user=YES时,所有的用户均不能切换到其他目录。 # ④ 当chroot_list_enable=NO,chroot_local_user=NO时,所有的用户均可以切换到其他目录。 FileZilla ftp传输:550 Permission denied 1. 找到配置文件文件 vsftpd.conf :$ locate vsftpd.conf(一般在/etc/vsftpd.conf) 2. 文件编辑:sudo vi vsftpd.conf 3. 在vsftpd.conf中找到 #write_enable=YES:命令行模式下输入/write_enable,回车 4. 重启vsftpd 5.0 01 Linux下清除屏幕的6个命令 标签: shell 你可能还喜欢这些文章![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 嘻嘻IT: 笔者是一个工作七八年的程序猿老鸟,从事涉及的技术栈主要包括PHP、Linux、Devops等,喜欢研究新技术,尝试新技术,提升技术自动化和开发效率,致力于write less,do more! 技术每年都会层出不穷,领域划分的越来越细,不可能学习所有的东西,保持对技术的好奇心,理解技术中核心思想,做一个有深度,有思想的开发! |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |