您当前的位置: 首页 > 学无止境 > 心得笔记 网站首页心得笔记
马哥linux运维学习笔记-ftp服务
发布时间:2019-03-04 17:03:40编辑:雪饮阅读()
安装vspftd
[root@mail ~]# rpm -ivh /test/Server/vsftpd-2.0.5-24.el5.i386.rpm
[root@mail ~]# service vsftpd start
Starting vsftpd for vsftpd: [ OK ]
抓包
linux端:
[root@mail pub]# tcpdump -i eth0 -nn -X -vv tcp port 21 and ip host 192.168.1.11
windows端:
C:\Users\Administrator>ftp 192.168.1.11
连接到 192.168.1.11。
220 (vsFTPd 2.0.5)
用户(192.168.1.11:(none)): anonymous
331 Please specify the password.
密码:
230 Login successful.
ftp>
linux端局部:
0x0020: 5010 002e cf72 0000 P....r..
21:29:27.214330 IP (tos 0x0, ttl 64, id 13026, offset 0, flags [DF], proto: TCP (6), length: 74) 192.168.1.11.21 > 192.168.1.5.63007: P, cksum 0x8827 (correct), 21:55(34) ack 17 win 46
0x0000: 4500 004a 32e2 4000 4006 846b c0a8 010b E..J2.@.@..k....
0x0010: c0a8 0105 0015 f61f a1ad fc88 2255 a612 ............"U..
0x0020: 5018 002e 8827 0000 3333 3120 506c 6561 P....'..331.Plea
0x0030: 7365 2073 7065 6369 6679 2074 6865 2070 se.specify.the.p
0x0040: 6173 7377 6f72 642e 0d0a assword...
21:29:27.441118 IP (tos 0x0, ttl 128, id 14714, offset 0, flags [DF], proto: TCP (6), length: 40) 192.168.1.5.63007 > 192.168.1.11.21: ., cksum 0xc78c (correct), 17:17(0) ack 55 win 2034
0x0000: 4500 0028 397a 4000 8006 3df5 c0a8 0105 E..(9z@...=.....
0x0010: c0a8 010b f61f 0015 2255 a612 a1ad fcaa ........"U......
0x0020: 5010 07f2 c78c 0000 0000 0000 0000 P.............
21:29:28.156862 IP (tos 0x0, ttl 128, id 14717, offset 0, flags [DF], proto: TCP (6), length: 47) 192.168.1.5.63007 > 192.168.1.11.21: P, cksum 0xf9db (correct), 17:24(7) ack 55 win 2034
0x0000: 4500 002f 397d 4000 8006 3deb c0a8 0105 E../9}@...=.....
0x0010: c0a8 010b f61f 0015 2255 a612 a1ad fcaa ........"U......
0x0020: 5018 07f2 f9db 0000 5041 5353 200d 0a P.......PASS...
21:29:28.157778 IP (tos 0x0, ttl 64, id 13027, offset 0, flags [DF], proto: TCP (6), length: 63) 192.168.1.11.21 > 192.168.1.5.63007: P, cksum 0xedb1 (correct), 55:78(23) ack 24 win 46
0x0000: 4500 003f 32e3 4000 4006 8475 c0a8 010b E..?2.@.@..u....
0x0010: c0a8 0105 0015 f61f a1ad fcaa 2255 a619 ............"U..
0x0020: 5018 002e edb1 0000 3233 3020 4c6f 6769 P.......230.Logi
0x0030: 6e20 7375 6363 6573 7366 756c 2e0d 0a n.successful...
21:29:28.441090 IP (tos 0x0, ttl 128, id 14719, offset 0, flags [DF], proto: TCP (6), length: 40) 192.168.1.5.63007 > 192.168.1.11.21: ., cksum 0xc774 (correct), 24:24(0) ack 78 win 2028
0x0000: 4500 0028 397f 4000 8006 3df0 c0a8 0105 E..(9.@...=.....
0x0010: c0a8 010b f61f 0015 2255 a619 a1ad fcc1 ........"U......
0x0020: 5010 07ec c774 0000 0000 0000 0000 P....t........
配置匿名用户可上传文件:
去除文件/etc/vsftpd/vsftpd.conf中"anon_upload_enable=YES"的注释
创建上传目录
[root@mail pub]# mkdir /var/ftp/upload
配置上传目录权限细则
[root@mail pub]# setfacl -m u:ftp:rwx /var/ftp/upload/
[root@mail pub]# getfacl /var/ftp/upload
getfacl: Removing leading '/' from absolute path names
# file: var/ftp/upload
# owner: root
# group: root
user::rwx
user:ftp:rwx
group::r-x
mask::rwx
other::r-x
windows端上传测试:
C:\Users\Administrator>ftp 192.168.1.11
连接到 192.168.1.11。
220 (vsFTPd 2.0.5)
用户(192.168.1.11:(none)): anonymous
331 Please specify the password.
密码:
230 Login successful.
ftp> put ntuser.ini
200 PORT command successful. Consider using PASV.
553 Could not create file.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
pub
upload
226 Directory send OK.
ftp: 收到 13 字节,用时 0.01秒 1.86千字节/秒。
ftp> cd upload
250 Directory successfully changed.
ftp> put ntuser.ini
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 File receive OK.
ftp: 发送 20 字节,用时 0.01秒 4.00千字节/秒。
ftp>
配置匿名用户可删除文件:
在文件/etc/vsftpd/vsftpd.conf中"# new directories.
#anon_mkdir_write_enable=YES "下方追加"anon_other_write_enable=YES "
windows下测试删除:
C:\Users\Administrator>ftp 192.168.1.11
连接到 192.168.1.11。
220 (vsFTPd 2.0.5)
用户(192.168.1.11:(none)): anonymous
331 Please specify the password.
密码:
230 Login successful.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
pub
upload
226 Directory send OK.
ftp: 收到 13 字节,用时 0.01秒 2.60千字节/秒。
ftp> cd upload
250 Directory successfully changed.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
ntuser.ini
226 Directory send OK.
ftp: 收到 12 字节,用时 0.00秒 6.00千字节/秒。
ftp> delete ntuser.ini
250 Delete operation successful.
ftp>
配置ftp日志:
在文件/etc/vsftpd/vsftpd.conf中将" xferlog_file=/var/log/xferlog "去除注释
windows下登录ftp:
C:\Users\Administrator>ftp 192.168.1.11
连接到 192.168.1.11。
220 (vsFTPd 2.0.5)
用户(192.168.1.11:(none)): anonymous
331 Please specify the password.
密码:
230 Login successful.
ftp>
linux下查看日志:
[root@mail upload]# cat /var/log/xferlog
Sat Mar 2 13:40:21 2019 1 192.168.1.5 0 /ntuser.ini a _ i a ? ftp 0 * i
Sat Mar 2 13:44:29 2019 1 192.168.1.5 20 /upload/ntuser.ini a _ i a ? ftp 0 * c
配置ftp目录欢迎信息(以配置upload目录为例):
[root@mail upload]# vim /var/ftp/upload/.message
[root@mail upload]# cat /var/ftp/upload/.message
hello,this is ftp upload.
please do not upload unknown file.
windows访问ftp目录测试:
C:\Users\Administrator>ftp 192.168.1.11
连接到 192.168.1.11。
220 (vsFTPd 2.0.5)
用户(192.168.1.11:(none)): anonymous
331 Please specify the password.
密码:
230 Login successful.
ftp> cd upload
250-hello,this is ftp upload.
250-please do not upload unknown file.
250 Directory successfully changed.
ftp> bye
221 Goodbye.
关键字词:linux,ftp