爱谁谁a 发表于 2015-5-28 10:23:40

debian做ftp服务器

  这两天重新安装ftp服务器,把流程记录下来,   
其中也是参考了网络上许多人的经验帖。   
    首先在有刻录机的电脑中下载   
ftp://debian.ustc.edu.cn/debian-cd/images/current/   
debian-31r0a-i386-binary-1.iso   
刻录光盘(把iso文件挂载或者虚拟光驱,然后镜像刻录就可以了)。   
ftp://debian.ustc.edu.cn/sources.list/   
下载相应源列表,目前stable版是sarge   
把列表内容抄录出来。   
光盘引导安装。   
硬盘分区,给根目录/ 2G应该足够了,剩下基本上是/home的,   
也可以给swap,大小和内存差不多就可以了。   
安装完成发现其实根目录连600M都没有用到(当然没有安装x)   
手动修改安装源列表,   
删掉原有的sources.list   
输入之前抄录的源   
选择手动安装软件,不安装桌面文件。   
可能会出现zhcon没有安装成功,那么在符号化终端看来中文就是乱码了,需要解决掉。   
提示说xfree86-common安装不成功,则在aptitude中删掉xfree86-common以及其关联   
的包。zhcon就能够安装成功了。   
在aptitude中安装lftp,vim,emacs等符号化的工具,   
检查wget,mutt等是否已经安装。   
# apt-get update   
# apt-get dist-upgrade   
更新   
修改ip地址   
编辑 /etc/network/interfaces 文件,用 sudo vi /etc/network/i   
nterfaces,修改 IP 地址。   
# This file describes the network interfaces available on your system   
# and how to activate them. For more information, see interfaces(5).   
# The loopback network interface   
auto lo   
iface lo inet loopback   
# This is a list of hotpluggable network interfaces.   
# They will be activated automatically by the hotplug subsystem.   
mapping hotplug   
      script grep   
      map eth0   
# The primary network interface   
auto eth0   
iface eth0 inet static   
      address 202.38.??.??   
      netmask 255.255.255.0   
      network 202.38.??.??   
      broadcast 202.38.??.??   
      gateway 202.38.??.??   
编辑 /etc/hosts 这个文件并且把新IP地址加进去,用 sudo vi /etc/hosts   
127.0.0.1       localhost.localdomain   localhost       userftp   
202.38.??.??   ???.ustc.edu.cn          userftp   
# The following lines are desirable for IPv6 capable hosts   
::1   ip6-localhost ip6-loopback   
fe00::0 ip6-localnet   
ff00::0 ip6-mcastprefix   
ff02::1 ip6-allnodes   
ff02::2 ip6-allrouters   
ff02::3 ip6-allhosts   
编辑 /etc/hostname,内容改为 ???.ustc.edu.cn   
/etc/init.d/networking restart 重新启动网络。   
安装 SSH
apt-get install ssh openssh-server   
现在可以通过其他电脑   
ssh **@202.38.??.??   
来远程管理服务器了。   
安装vsftp   
apt-get install vsftpd   
配置/etc/vsftpd/vsftpd.conf   
以下是我的vsftpd.conf内容   
===============================================================   
#服务器以standalong模式运行,这样可以进行下面的控制   
listen=YES   
#接受匿名用户   
anonymous_enable=YES   
#匿名用户login时不询问口令   
no_anon_password=YES   
# 接受本地用户   
local_enable=YES   
# 可以上传(全局控制).若想要匿名用户也可上传则需要设置anon_upload_enable=YES,   
# 若想要匿名用户可以建立目录则需要设置anon_mkdir_write_enable=YES.这里禁止匿   
# 名用户上传,所以不设置这两项.   
write_enable=YES   
#本地用户上传文件的umask   
local_umask=022   
#如果设为YES,匿名登入者会被允许上传目录的权限,当然,匿名使用者必须要有对   
#上层目录的写入权。   
anon_upload_enable=YES   
#定义匿名登入的使用者名称。默认值为ftp   
ftp_username=ftp   
#如果设为YES,匿名登入者会被允许新增目录,当然,匿名使用者必须要有对上层   
#目录的写入权。   
anon_mkdir_write_enable=YES   
# 为YES则进入目录时显示此目录下由message_file选项指定的文本文件(,默认为.messa   
ge)的内容   
dirmessage_enable=YES   
#本地用户login后所在目录,若没有设置此项,则本地用户login后将在他的home目录   
#(/etc/passwd的第六个字段)中.匿名用户的对应选项是anon_root   
#local_root=/home   
anon_root=/home/ftp/   
# 使用上传/下载日志,日志文件默认为/var/log/vsftpd.log,可以通过xferlog_file选   
项修改   
xferlog_enable=YES   
# Make sure PORT transfer connections originate from port 20 (ftp-data).   
connect_from_port_20=YES   
#日志使用标准xferlog格式   
xferlog_std_format=YES   
# You may change the default value for timing out a data connection.   
data_connection_timeout=120   
# 关闭本地用户chroot()   
chroot_local_user=NO   
#设置为yes则下面的控制有效。   
#开启要设置chroot()用户项.   
chroot_list_enable=YES   
# (default follows)   
#指定要设置chroot()的特定用户文件   
chroot_list_file=/etc/vsftpd.chroot_list   
#若设置为YES则记录在userlist_file选项指定文件(默认是/etc/vsftpd.user_list)中   
的用   
#户无法login,并且将检察下面的userlist_deny选项   
userlist_enable=YES   
#若为NO,则仅接受记录在userlist_file选项指定文件(默认是/etc/vsftpd.user_list)   
中的   
#用户的login请求.若为YES则不接受这些用户的请求.   
userlist_deny=NO   
#注意!!!vsftpd还要检察/etc/vsftpd.ftpusers文件,记录在这个文件中的用户将无法lo   
gin!!   
#匿名用户的传输比率(b/s)   
anon_max_rate=512000   
#本地用户的传输比率(b/s)   
local_max_rate=1024000   
#可接受的最大client数目   
max_clients=100   
#每个ip的最大client数目   
max_per_ip=5   
# This option should be the name of a directory which is empty.Also, the   
# directory should not be writable by the ftp user. This directory is used   
# as a secure chroot() jail at times vsftpd does not require filesystem   
# access.   
secure_chroot_dir=/var/run/vsftpd   
#   
# This string is the name of the PAM service vsftpd will use.   
pam_service_name=vsftpd   
tcp_wrappers=YES   
#   
# This option specifies the location of the RSA certificate to use for SSL   
# encrypted connections.   
rsa_cert_file=/etc/ssl/certs/vsftpd.pem   
# 每一个联机,都能以独立的process 来呈现.   
setproctitle_enable=YES   
#若是启动,所有匿名上传数据的拥有者将被更换为chown_username   
#当中所设定的使用者。这样的选项对于安全及管理,是很有用的。   
chown_uploads=YES   
#这里可以定义当匿名登入者上传档案时,该档案的拥有者将被置换的   
#使用者名称。预设值为root。   
chown_username=root   
====================================================================   
增加用户名一堆(都属于ftpuser组的)   
groupadd ftpuser   
mkdir /home/john/   
useradd -g ftpuser john   
passwd john   
更改文件所有者以及权限   
chown -v -R john.ftpuser /home/john/   
chmod -v -R 700 /home/john/   
给ftpuser组所有用户共享一个文件夹,做一个连接   
ln -v -s /home/ftpuser/ /home/john/ftpuser   
在每个用户的文件夹中设置.message   
做欢迎界面   
编辑/etc/vsftpd.user_list   
列举所有的用户列表。   
编辑/etc/vsftpd.chroot_list   
填写不准进入上层目录的用户名   
给/home/ftp/中允许匿名写的目录修改权限。   
chmod -v 777 /home/ftp/temp/   
做两个定时工作   
crontab -e   
在里面写   
0 4 * * 1 rm -rf /home/ftp/incoming/temp/*   
# 每星期一凌晨4点清空/home/ftp/incoming/temp/文件夹   
0 5 10 * * /sbin/reboot   
# 每个月10日凌晨5点重新启动电脑   
reboot或者重启vsftpd   
好了,ftp服务器架构完成了。
页: [1]
查看完整版本: debian做ftp服务器