IT猫扑网:您身边最放心的安全下载站! 最新更新| 软件分类| 专题汇总| 手机版

您当前所在位置:IT猫扑网 > 服务器 > FTP服务器 > linux下ftp服务器的搭建

linux下ftp服务器的搭建

时间:2015-06-28 00:00 来源:IT猫扑网|http://www.itmop.com/ 作者:网管联盟 我要评论(0)

  RHEL4中ftp服务器的搭建

  首先修改配置文件使主机获得永久ip地址

  # vi /etc/sysconfig/network-scripts/ifcfg-eth0

  DEVICE=eth0

  BOOTPROTO=static

  IPADDR=172.16.16.111

  NETMASK=255.255.0.0

  GATEWAY=172.16.16.1

  ONBOOT=yes

  TYPE=Ethernet

  重启配置文件使之生效

  # /etc/init.d/network restart

  Shutting down interface eth0:  [  OK  ]

  Shutting down loopback interface:  [  OK  ]

  Setting network parameters:  [  OK  ]

  Bringing up loopback interface:  [  OK  ]

  Bringing up interface eth0:  [  OK  ]

  需要关掉iptables系统防火墙,使用命令:

  # service iptables stop

  把安全级别调低

  # vi /etc/selinux/config

  把其中的:SELINUXTYPE=targeted改为SELINUXTYPE=disabled

  在系统中vsftpd并没被默认安装,需要使用rpm命令安装一下

  它在RHEL4的第1张光盘中,包文件的名称是vsftpd-2.0.1-5.i386.rpm

  首先需要挂载光盘

  # mount /dev/cdrom /media/cdrom

  # cd /media/cdrom/RedHat/RPMS

  # ls -l vsftpd*

  -rw-r--r--  25 root root 122195 Jan  6  2005 vsftpd-2.0.1-5.i386.rpm

  挂载上去后,把它安装上去

  # rpm -ivh vsftpd-2.0.1-5.i386.rpm

  warning: vsftpd-2.0.1-5.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e

  Preparing...    ########################################### [100%]

  我们看一下vsftpd.conf的配置文件

  # grep -v '#' /etc/vsftpd/vsftpd.conf(去除注释行后的配置文件)

  anonymous_enable=YES     //anonymous_enable设置为yes时,ftp服务器允许匿名登录,即用户可使用用户名ftp或anonymous进行ftp登录,登录口令为用户E-mail地址。

  local_enable=YES     //local_enable设置为yes时允许本地用户登录,本地用户指lunux系统中的用户账号。

  write_enable=YES     //write_enable设置为yes时,ftp服务器开放对本地用户的写权限

  local_umask=022     //local_umask设置项设置本地用户的文件生成掩码,配置文件中的设置为022。

  dirmessage_enable=YES    //dirmessage_enable设置为yes时,当切换到ftp服务器中的某个目录时,将显示该目录下的&.message&隐含文件的内容.

  xferlog_enable=YES     //xferlog_enable设置为yes时,ftp服务器将启用上传和下载日志。

  connect_from_port_20=YES     //connect_from_port_20设置为yes时,ftp服务器将启用ftp数据端口的连接请求。

  xferlog_std_format=YES     //xferlog_std_format设置为yes时,ftp服务器将使用标准的ftpd xferlog日志格式。

  pam_service_name=vsftpd      //pam_service_name设置PAM认证服务的配置文件名称,该文件保存在&/etc/pam.d/&目录下。

  userlist_enable=YES     //userlist_enable设置为yes时,ftp服务器将检查userlist_file设置文件中指定的用户是否可以访问vsftpd服务器;userlist_file配置项的默认值是&/etc/vsftpd.usr_list&文件。

  listen=YES     //listen设置为yes时,ftp服务器将处于独立启动模式。

  tcp_wrappers=YES     //tcp_wrappers设置为yes时,ftp服务器将使用tcp_wrappes作为主机访问控制方式。tcp_wrappers可以实现linux系统中网络服务的基于主机地址的访问控制,在&/etc&目录中的hosts.allow和host.deny两个文件用于设置tcp_wrappers的访问控制,hosts.allow文件设置允许访问记录,host.deny文件设置拒绝访问记录。

  启动vsftpd服务器

  # service vsftpd start

  Starting vsftpd for vsftpd: [  OK  ]

  关闭可以使用:

  service vsftpd stop

  Shutting down vsftpd: [  OK  ]

  查看服务器的运行状态使用:

  # service vsftpd status

  vsftpd is stopped

  添加两个本地用户,使用本地用户登录ftp

  # useradd aa

  # passwd aa

  # useradd bb

  # passwd bb

  并改变目录的属主和属组

  # chown aa.aa /home/aa

  # chown bb.bb /home/bb

  # ls -l /home

  total 24

  drwx------  4 aa   aa   4096 May 26 12:15 aa

  drwx------  4 bb   bb   4096 May 26 12:16 bb

  设置宿主目录权限

  # chmod 770 /home/aa

  # chmod 770 /home/bb

  # ls -l /home

  total 24

  drwxrwx---  4 aa   aa   4096 May 26 12:15 aa

  drwxrwx---  4 bb   bb   4096 May 26 12:16 bb

  这时可以登录ftp

  1、使用匿名用户登录

  # ftp 172.16.16.121

  Connected to 172.16.16.121.

  220 (vsFTPd 2.0.1)

  530 Please login with USER and PASS.

  530 Please login with USER and PASS.

  KERBEROS_V4 rejected as an authentication type

  Name (172.16.16.121:root): anonymous

  331 Please specify the password.

  Password:

  230 Login successful.

  Remote system type is UNIX.

  Using binary mode to transfer files.

  ftp> ls

  227 Entering Passive Mode (172,16,16,121,208,47)

  150 Here comes the directory listing.

  drwxr-xr-x    2 0  0      4096 Oct 04  2004 pub

  226 Directory send OK.

  其中匿名用户登录使用ftp或anonymous作为ftp登录的用户名,在vsftpd的默认设置时输入任何字符串或直接回车都可以登录,匿名用户登录后将以ftp服务器系统中的&/var/ftp&目录作为匿名用户的ftp根目录。

#p#副标题#e#

  2、使用本地用户登录

  # ftp 172.16.16.121

  Connected to 172.16.16.121.

  220 (vsFTPd 2.0.1)

  530 Please login with USER and PASS.

  530 Please login with USER and PASS.

  KERBEROS_V4 rejected as an authentication type

  Name (172.16.16.121:root): aa

  331 Please specify the password.

  Password:

  230 Login successful.

  Remote system type is UNIX.

  Using binary mode to transfer files.

  ftp> ls

  227 Entering Passive Mode (172,16,16,121,223,86)

  150 Here comes the directory listing.

  -rw-r--r--    1 0  0  19 May 26 03:48 11.txt

  226 Directory send OK.

  使用put命令可以将ftp客户机中的文件上传到ftp服务器中。

  ftp> put 22.txt

  local: 22.txt remote: 22.txt

  227 Entering Passive Mode (172,16,16,121,86,19)

  150 Ok to send data.

  226 File receive OK.

  30 bytes sent in 0.00086 seconds (34 Kbytes/s)

  使用get命令可以将ftp服务器中的文件下载到ftp客户机中。

  ftp> get 22.txt

  local: 22.txt remote: 22.txt

  227 Entering Passive Mode (172,16,16,121,143,82)

  150 Opening BINARY mode data connection for 22.txt (30 bytes).

  226 File send OK.

  30 bytes received in 0.0005 seconds (58 Kbytes/s)

  不过使用本地ftp用户账号存在一定的安全性,首先它是系统账号,一旦ftp服务器出现安全漏洞会对整个ftp服务器所在的linux主机造成威胁;另外就是本地用户账号可以离开用户宿主目录,转换到系统中的其他目录中,这对系统的安全有着一定的威胁。

  可是设置ftp本地用户禁锢在宿主目录中,这样可以防止它切换到其他的目录中。

  在vsftpd服务器的配置文件vsftpd.conf中添加配置项chroot_local_user设置为YES,vsftpd服务器将会把本地用户禁锢在用

关键词标签:linux,ftp服务器

相关阅读 Linux下FTP的配置与应用 什么是ftp及ftp服务器 FTP出错解决和分析 proftp 安装设定文档 使用Win 2003搭建安全文件服务器 让Proftpd 的数据库模块支持MD5验证

文章评论
发表评论

热门文章 Linux下FTP的配置与应用 Linux下FTP的配置与应用 使用Win 2003搭建安全文件服务器 使用Win 2003搭建安全文件服务器 linux服务samba的详细配置 linux服务samba的详细配置 图解Windows xp—FTP服务器配置 图解Windows xp—FTP服务器配置 Linux文件传送命令SCP(Secure Copy) Linux文件传送命令SCP(Secure Copy) 在Windows 2003下搭建FTP服务器 在Windows 2003下搭建FTP服务器

相关下载

人气排行 vsftp配置大全---超完整版 IIS6.0打造FTP服务器完全图文详解 使用Win 2003搭建安全文件服务器 图解Windows xp—FTP服务器配置 linux服务samba的详细配置 在Windows 2003下搭建FTP服务器 FTP登陆错误详解 Windows内置FTP服务器高级配置 Windows XP系统下架设FTP服务器的步骤 不用工具也可以修改Serv-u默认43958端口 使用CesarFTP架设FTP服务器 FTP空间不足 Windows 系统性能监控来报警