资源共享的服务器
1.ftp: 跨平台,支持tcp/ip的平台就可以,使用ftp协议
2.Samba: 使用smb协议
linux<->windows资源共享
3.nfs: 使用rpc协议
远程访问协议
Server种类:
Windows
1) iis
2) server-u
Linux
Wu-ftp
Vsftpd
Pureftp
ftp 是 client/server的模式
client访问ftp时方式:
1.tcp/ip cmd
2.浏览器
3.Cuteftp leapftp flashxp
--为了安全可以使用ssl
ftp 工作方式
(主动和被动由client决定)
1.主动方式
PORT(主动)方式的连接过程是:客户端向服务器的FTP端口(默认是21)发送连接请求,服务器接受连接,建立一条命令链路。当需要传送数据时,客户端在命令链路上用PORT命令告诉服务器:“我打开了XXXX端口,你过来连接我”。于是服务器从20端口向客户端的XXXX端口发送连接请求,建立一条数据链路来传送数据。
不安全,启用内部服务器放置在防火墙后,防火墙起不到作用。
如果通过代理上网的话,就不能用主动模式,因为服务器连接的是上网代理服务器的端口,而不是连接客户端的端口,而且有时候,客户端也不是轻易就开门的,因为有防火墙阻挡,除非客户端开放大于1024的高端端口。
2.被动方式
PASV(被动)方式的连接过程是:客户端向服务器的FTP端口(默认是21)发送连接请求,服务器接受连接,建立一条命令链路。当需要传送数据时,服务器在命令链路上用PASV命令告诉客户端:“我打开了XXXX端口,你过来连接我”。于是客户端向服务器的XXXX端口发送连接请求,建立一条数据链路来传送数据。
传输模式
1. ascii
2. binary(默认)
访问方式
ftp 有身份验证
lftp 没有身份验证
ftp指令
ftp> help
Commands may be abbreviated. Commands are:
! cr mdir proxy send
$ delete mget sendport site
account debug mkdir put size
append dir (查看远程) mls pwd status
ascii disconnect mode quit struct
bell form modtime quote system
binary get mput recv sunique
bye glob newer reget tenex
case hash nmap rstatus trace
ccc help nlist rhelp type
cd idle ntrans rename user
cdup image open reset umask
chmod lcd passive restart verbose
clear ls private rmdir ?
close macdef prompt runique
cprotect mdelete protect safe
ftp>
get /mget
put /mput
!dir查看本地的
lcd 本地的
[root@mail Server]# rpm -ivh vsftpd-2.0.5-12.el5.i386.rpm
[root@mail Server]# service vsftpd start
Starting vsftpd for vsftpd: [ OK ]
[root@mail Server]#
[root@mail pub]# vim /etc/vsftpd/vsftpd.conf
anonymous_enable=YES
local_enable=YES
write_enable=YES
anon_umask=073 ----屏蔽权限,解决可以上传不可以可以下载
anon_upload_enable=YES --匿名用户有上传的权限
anon_mkdir_write_enable=YES
anon_other_write_enable=YES --匿名用户创建的文件可以被其他用户读取的权限,更改目录名称和上传的目录的权限
dirmessage_enable=YES --目录说明的文件
--要打开日志文件才会有传输日志
xferlog_enable=YES
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
#要显示详细日志,请求应答log
#xferlog_std_format=no
#log_ftp_protocol=no
--会显示详细日志信息,必须是非标准日志模式下
#默认传输是二进制
#ascii_upload_enable=YES
#ascii_download_enable=YES
# You may fully customise the login banner string:
ftpd_banner=Welcome to lwy's FTP service.
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
deny_email_enable=YES
banned_email_file=/etc/vsftpd/banned_emails
#添加拒绝的邮箱
[root@mail pub]# man 5 vsftpd.conf
dirmessage_enable
If enabled, users of the FTP server can be shown messages when
they first enter a new directory. By default, a directory is
scanned for the file .message, but that may be overridden with
the configuration setting message_file.
Default: NO (but the sample config file enables it)
anon_other_write_enable
If set to YES, anonymous users will be permitted to perform
write operations other than upload and create directory, such as
deletion and renaming. This is generally not recommended but
included for completeness.
Default: NO
本地用户登录
[root@mail pub]# lftp -u user1 127.0.0.1
Password:
lftp [email protected]:~> user user2
Password:
lftp [email protected]:~> pwd
ftp://[email protected]
lftp [email protected]:~> cd pub
cd: Access failed: 550 Failed to change directory. (/home/user2/pub)
lftp [email protected]:~> bye
[root@mail ~]# cd /var/ftp
[root@mail ftp]# chmod o+wt pub/ --改变权限pub目录可写只有创建的人才能删除
创建目录说明文件
[root@mail pub]# vim .message
This is pub dir
[root@mail log]# ftp 127.0.0.1
Connected to 127.0.0.1.
220 (vsFTPd 2.0.5)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (127.0.0.1:root): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/"
ftp> cd pub
250-This is pub dir
250 Directory successfully changed.
ftp> bye
221 Goodbye.
拒绝的邮箱密码登陆的测试
--lftp用户访问没有目录切换说明
[root@mail log]# lftp 127.0.0.1
lftp 127.0.0.1:~> cd pub
cd ok, cwd=/pub
lftp 127.0.0.1:/pub> dir
drwx---r-- 2 14 50 4096 Aug 27 17:48 dd
drwx---r-- 2 14 50 4096 Aug 27 17:05 ff
drwxr-xr-x 2 0 0 4096 Aug 27 17:48 ll
drwxr-xr-x 2 0 0 4096 Aug 27 17:48 yy
drwx---r-- 2 14 50 4096 Aug 27 17:05 新文件夹 (3)
lftp 127.0.0.1:/pub> get ll
get: Access failed: 550 Failed to open file. (ll)
lftp 127.0.0.1:/pub> get dd
get: Access failed: 550 Failed to open file. (dd)
lftp 127.0.0.1:/pub> get 123.txt
6 bytes transferred
[root@mail pub]# tail /var/log/vsftpd.log
Sat Aug 27 18:12:35 2011 1 127.0.0.1 0 /pub/ll b _ o a lftp@ ftp 0 * i
Sat Aug 27 18:12:42 2011 1 127.0.0.1 0 /pub/dd b _ o a lftp@ ftp 0 * i
Sat Aug 27 18:13:55 2011 1 192.168.101.177 6 /pub/123.txt.txt b _ i a IEUser@ ftp 0 * c
Sat Aug 27 18:15:20 2011 1 127.0.0.1 6 /pub/123.txt b _ o a lftp@ ftp 0 * c
[root@mail pub]#
[root@mail pub]# ftp 127.0.0.1
Connected to 127.0.0.1.
220 Welcome to lwy's FTP service.
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (127.0.0.1:root): user1
331 Please specify the password.
Password: --输入[email protected]
530 Login incorrect.
Login failed.
ftp>
--防止用户邮箱登陆ftp