系统之家 - Windows操作系统&装机软件下载网站!

当前位置: 首页  >  教程资讯  >  电脑教程 linux配置ftp服务

linux配置ftp服务

时间:2023-06-02 16:16:41 来源: 人气:

   Redhat9 配置FTP,  2、编辑/etc/vsftpd/vsftpd.conf文件,  修改端口,  Step1. 修改/etc/vsftpd/vsftpd.conf,  `新增底下一行,  listen_port=2121,  Step2. 重新启动vsftpd,  [root@home vsftpd]# /sbin/service vsftpd restart,  Shutting down vsftpd: OK ],  Starting vsftpd for vsftpd: OK ],  特定使用者peter、john 不得变更目录,  使用者的预设目录为/home/username,若是我们不希望使用者在ftp 时能够,  切换到上一层目录/home,则可参考以下步骤。,  Step1. 修改/etc/vsftpd/vsftpd.conf,  将底下三行,  #chroot_list_enable=YES,  # (default follows),  #chroot_list_file=/etc/vsftpd.chroot_list,  改为,  chroot_list_enable=YES,  # (default follows),  chroot_list_file=/etc/vsftpd/chroot_list //需新增此文件,  Step2. 新增一个档案: /etc/vsftpd/chroot_list,  内容增加两行:,  peter,  john,  Step3. 重新启动vsftpd,  [root@home vsftpd]# /sbin/service vsftpd restart,  Shutting down vsftpd: OK ],  Starting vsftpd for vsftpd: OK ],  若是peter 欲切换到根目录以外的目录,则会出现以下警告:,  ftp>; cd /home,  550 Failed to change directory.,  取消anonymous 登入,  若是读者的主机不希望使用者匿名登入,则可参考以下步骤。,  Step1. 修改/etc/vsftpd/vsftpd.conf,  将,  anonymous_enable=YES,  改为,  anonymous_enable=NO,  安排欢迎话语,  若是我们希望使用者在登入时,能够看到欢迎话语,可能包括对该主机的,  说明,或是目录的介绍,可参考以下步骤。,  首先确定在/etc/vsftpd/vsftpd.conf 当中是否有底下这一行,  dirmessage_enable=YES,  RedHat9 的默认值是有上面这行的。,  接着,在各目录之中,新增名为.message 的档案,再这边假设有一个使用,  者test1,且此使用者的根目录下有个目录名为abc,那首先我们在/home/test1,  之下新增.message,内容如下:,  Hello~ Welcome to the home directory,  This is for test only...,  接着,在/home/test1/abc 的目录下新增.message,内容如下:,  Welcome to abcs directory,  This is subdir...,  那么,当使用者test1 登入时,会看到以下讯息:,  230- Hello~ Welcome to the home directory,  230-,  230- This is for test only...,  230-,  若是切换到abc 的目录,则会出现以下讯息:,  250- Welcome to abcs directory,  250-,  250- This is subdir ...,  对于每一个联机,以独立的process 来运作,  一般启动vsftp 时,我们只会看到一个名为vsftpd 的process 在运作,但若,  是读者希望每一个联机,都能以独立的process 来呈现,则可执行以下步骤。,  Step1. 修改/etc/vsftpd/vsftpd.conf,  新增底下一行,  setproctitle_enable=YES,  Step2. 重新启动vsftpd,  [root@home vsftpd]# /sbin/service vsftpd restart,  Shutting down vsftpd: OK ],  Starting vsftpd for vsftpd: OK ],  使用ps -ef 的指令,可以看告不同使用者联机的情形,如下图所示:,  [root@home vsftpd]# ps -ef|grep ftp,  root 2090 1 0 16:41 pts/0 00:00:00 vsftpd: LISTENER,  nobody 2120 2090 0 17:18 ? 00:00:00 vsftpd: 192.168.10.244:,  connected,  test1 2122 2120 0 17:18 ? 00:00:00 vsftpd: 192.168.10.244/test1:,  IDLE,  nobody 2124 2090 0 17:19 ? 00:00:00 vsftpd: 192.168.10.244:,  connected,  test2 2126 2124 0 17:19 ? 00:00:00 vsftpd: 192.168.10.244/test2:,  IDLE,  root 2129 1343 0 17:20 pts/0 00:00:00 grep ftp,  [root@home vsftpd]#,  限制传输档案的速度:本机的使用者最高速度为200KBytes/s,匿名登入,  者所能使用的最高速度为50KBytes/s,  Step1. 修改/etc/vsftpd/vsftpd.conf,  新增底下两行,  anon_max_rate=50000,  local_max_rate=200000,  Step2. 重新启动vsftpd,  [root@home vsftpd]# /sbin/service vsftpd restart,  Shutting down vsftpd: OK ],  Starting vsftpd for vsftpd: OK ],  在这边速度的单位为Bytes/s,其中anon_max_rate 所限制的是匿名登入的,  使用者,而local_max_rate 所限制的是本机的使用者。VSFTPD 对于速度的限,  制,范围大概在80%到120%之间,也就是我们限制最高速度为100KBytes/s,,  但实际的速度可能在80KBytes/s 到120KBytes/s 之间,当然,若是频宽不足,  时,数值会低于此限制。,  建置一个防火墙下的ftp server,使用PORT FTP mode:预设的ftp,  port:21 以及ftp data port:20,  启动VSFTPD 之后执行以下两行指令,只允许port 21 以及port 20 开放,,  其它关闭。,  iptables -A INPUT -p tcp -m multiport --dport 21,20 -j ACCEPT,  iptables -A INPUT -p tcp -j REJECT --reject-with tcp-reset,  将vsftpd 并入XINETD,  若是读者希望将vsftpd 并入XINETD 之中,也就是7.x 版的预设设定,那,  么读者可以执行以下步骤。,  Step1. 修改/etc/vsftpd/vsftpd.conf,  将,  listen=YES,  改为,  listen=NO,  Step2. 新增一个档案: /etc/xinetd.d/vsftpd,  内容如下:,  service vsftpd,  {,  disable = no,  socket_type = stream,  wait = no,  user = root,  server = /usr/sbin/vsftpd,  port = 21,  log_on_success += PID HOST DURATION,  log_on_failure += HOST,  },  Step3. 重新启动xinetd,  [root@home vsftpd]# /sbin/service xinetd restart,  Stopping xinetd: OK ],  Starting xinetd: OK ],  3、常见错误,  ftp客户连接常见故障现象,  现象0:,  > ftp: connect :连接被拒绝,  原因: 服务没启动,  解决: # chkconfig vsftpd on,  现象1:,  500 OOPS: cannot open user list file,  原因: 不存在文件“/etc/vsftpd.user_list”或文件中不存在该帐户,  解决: # echo username >> /etc/vsftpd.user_list,  现象2:,  530 Permission denied.,  Login failed.,  原因: “/etc/vsftpd.user_list”文件中不存在当前登陆用户,  解决: # echo username >> /etc/vsftpd.user_list,  现象3:,  500 OOPS: cannot open chroot() user list file,  Login failed.,  原因: 不存在文件“/etc/vsftpd.chroot_list”,  解决: # echo username >> /etc/vsftpd.chroot_list,  现象4:,  500 OOPS: missing value in config file,  Connection closed by remote host.,  原因: “=”等号前值有问题,或只有一个空格,  解决: 修正相应的值即可,可能过 diff 来比较查找,  现象5:,  500 OOPS: bad bool value in config file,  Connection closed by remote host.,  原因: “=”等号后值有问题,  解决: 将“=”等号后值确认修改,  现象6:,  500 OOPS: unrecognised variable in config file,  Connection closed by remote host.,  原因: 参数前有空格,  解决: 将参数前空格删除,  现象7、,  确认存在“local_enable=YES”,但本地用户无法登陆,  原因: 验证参数被误删除,  解决: 添加“pam_service_name=vsftpd”,  现象8、,  500 OOPS: chdir,  500 OOPS: child died,  Connection closed by remote host.,  原因: 用户主目录没有权限或没有主目录,  解决: 正确设置用户主目录权限,  553 Could not create file.,  要解决这个问题只要:,  1. setsebool -P ftpd_disable_trans 1,  2. service vsftpd restart,  1、设置selinux,  vi /etc/sysconfig/selinux,  将其中的SELINUX=enforcing改为SELINUX=disabled,  2、设置如下,  setsebool -P allow_ftpd_full_access 1,  chmod -R 765 /etc/home,  1、 查看 SELinux 的状态: sestatus -b | grep ftp,  2、 在出现的结果中可以看到,  ftp_home_dir off,  tftpd_disable_trans off,  之类。我们现在只要把其中之一设置为on就可以啦。,  3、 setsebool -P ftpd_disable_trans on 或者 setsebool -P ftp_home_dir on,  4、 重启vsftpd: service vsftpd restart,

作者

教程资讯

电脑教程排行

系统教程

系统主题