配置ftp服務器只能上傳不能進行其他操作

又到期末考試了,今年當了數據挖掘助教,課程有一道編程大作業,需要搭建ftp服務器,實現文件上傳,但是禁止下載重命名。
服務器系統是ubuntu12.04 server,使用的ftp服務器也是linux下大名鼎鼎的vsftpd,配置如下:
1創建用戶dm,將其登錄終端設置爲/bin/false,防止用戶ssh登錄

1
useradd -m -s /bin/false dm

2將/bin/false加入/etc/shells中,使其可以使用dm用戶進行ftp登錄

1
echo "/bin/bash">>/etc/shells

3配置vsftpd.conf,禁止用戶訪問上層目錄.自行創建/etc/vsftpd.chroot_list,不添加任何用戶,在vsftpd.chroot_list中得用戶可以切換到上層目錄,我們這裏需要禁止dm用戶。主要配置如下:

1
2
3
chroot_local_user=YES
chroot_list_enable=YES                                                                                                                                       
chroot_list_file=/etc/vsftpd.chroot_list

4添加相應權限,防止用戶下載重命名
使用cmds_allows命令配置,將不允許的命令(重命名,下載,刪除,創建文件夾)除去即可:

1
cmds_allowed=FEAT,REST,CWD,LIST,MDTM,NLST,PASS,PASV,PORT,PWD,QUIT,RMD,SIZE,STOR,TYPE,USER,ACCT,APPE,CDUP,HELP,MODE,NOOP,REIN,STAT,STOU,STRU,SYST

主要命令解釋如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
=====================最常用的,出去對應命令即可========================
MKD - make a remote directory 新建文件夾
NLST - name list of remote directory
PWD - print working directory 顯示當前工作目錄
RETR - retrieve a remote file 下載文件
STOR - store a file on the remote host 上傳文件 
DELE - delete a remote file 刪除文件
RMD - remove a remote directory 刪除目錄
RNFR - rename from 重命名
RNTO - rename to 重命名
====================================================================
ABOR - abort a file transfer 取消文件傳輸
CWD - change working directory 更改目錄
DELE - delete a remote file 刪除文件
LIST - list remote files 列目錄
MDTM - return the modification time of a file 返回文件的更新時間
MKD - make a remote directory 新建文件夾
NLST - name list of remote directory
PASS - send password
PASV - enter passive mode 
PORT - open a data port 打開一個傳輸端口
PWD - print working directory 顯示當前工作目錄
QUIT - terminate the connection 退出
RETR - retrieve a remote file 下載文件
RMD - remove a remote directory
RNFR - rename from
RNTO - rename to
SITE - site-specific commands
SIZE - return the size of a file 返回文件大小
STOR - store a file on the remote host 上傳文件
TYPE - set transfer type
USER - send username
更多文章請前往小胖軒.

發佈了117 篇原創文章 · 獲贊 23 · 訪問量 90萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章