(1)安裝vsftp:
[centos@localhost ~]$ sudo yum install vsftpd #sudo 給普通用戶添加root權限,用root用戶登錄不用使用sudo
(2)完成安裝,配置vsftp:
vsftp的配置文件在:/etc/vsftpd/目錄下:
vsftpd.conf //vsftp的配置文件
user_list、ftpusers //禁止登錄vsftp的用戶名單
[centos@localhost vsftpd]$ sudo vim /etc/vsftpd/vsftpd.conf #打開配置文件 # Example config file /etc/vsftpd/vsftpd.conf # # The default compiled in settings are fairly paranoid. This sample file # loosens things up a bit, to make the ftp daemon more usable. # Please see vsftpd.conf.5 for all compiled in defaults. # # READ THIS: This example file is NOT an exhaustive list of vsftpd options. # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's # capabilities. # # Allow anonymous FTP? (Beware - allowed by default if you comment this out). anonymous_enable=NO #是否允許匿名用戶登錄 # # Uncomment this to allow local users to log in. local_enable=YES #是否允許本地用戶登錄 # # Uncomment this to enable any form of FTP write command. write_enable=YES #登錄用戶是否具有文件的寫權限 # # Default umask for local users is 077. You may wish to change this to 022, # if your users expect that (022 is used by most other ftpd's) local_umask=022 #本地文件的文件掩碼 # # Uncomment this to allow the anonymous FTP user to upload files. This only # has an effect if the above global write enable is activated. Also, you will # obviously need to create a directory writable by the FTP user. anon_upload_enable=YES #是否允許匿名用戶上傳文件 # # Uncomment this if you want the anonymous FTP user to be able to create # new directories. anon_mkdir_write_enable=YES #是否允許匿名用戶創建文件夾 # # Activate directory messages - messages given to remote users when they # go into a certain directory. dirmessage_enable=YES #激活目錄信息,當用戶更改目錄時,出現提示信息 # # The target log file can be vsftpd_log_file or xferlog_file. # This depends on setting xferlog_std_format parameter xferlog_enable=YES #啓用上傳和下載的日誌功能 # # Make sure PORT transfer connections originate from port 20 (ftp-data). connect_from_port_20=YES #啓動ftp數據連接端口請求 # # If you want, you can arrange for uploaded anonymous files to be owned by # a different user. Note! Using "root" for uploaded files is not # recommended! #chown_uploads=YES #chown_username=whoever # # The name of log file when xferlog_enable=YES and xferlog_std_format=YES # WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log #xferlog_file=/var/log/xferlog #日誌文件的默認目錄 # # Switches between logging into vsftpd_log_file and xferlog_file files. # NO writes to vsftpd_log_file, YES to xferlog_file xferlog_std_format=YES # # You may change the default value for timing out an idle session. #idle_session_timeout=600 # # You may change the default value for timing out a data connection. #data_connection_timeout=120 #空閒會話中斷時間默認是2分鐘 # # It is recommended that you define on your system a unique user which the # ftp server can use as a totally isolated and unprivileged user. #nopriv_user=ftpsecure # # Enable this and the server will recognise asynchronous ABOR requests. Not # recommended for security (the code is non-trivial). Not enabling it, # however, may confuse older FTP clients. #async_abor_enable=YES # # By default the server will pretend to allow ASCII mode but in fact ignore # the request. Turn on the below options to have the server actually do ASCII # mangling on files when in ASCII mode. # Beware that on some FTP servers, ASCII support allows a denial of service # attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd # predicted this attack and has always been safe, reporting the size of the # raw file. # ASCII mangling is a horrible feature of the protocol. #ascii_upload_enable=YES #ascii_download_enable=YES #是否允許使用ASCII格式來上傳下載文件 # # You may fully customise the login banner string: #ftpd_banner=Welcome to blah FTP service. #在ftp服務器中設置歡迎登陸 # # You may specify a file of disallowed anonymous e-mail addresses. Apparently # useful for combatting certain DoS attacks. #deny_email_enable=YES # (default follows) #banned_email_file=/etc/vsftpd/banned_emails # # You may specify an explicit list of local users to chroot() to their home # directory. If chroot_local_user is YES, then this list becomes a list of # users to NOT chroot(). #chroot_local_user=YES #chroot_list_enable=YES # (default follows) #chroot_list_file=/etc/vsftpd/chroot_list # # You may activate the "-R" option to the builtin ls. This is disabled by # default to avoid remote users being able to cause excessive I/O on large # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume # the presence of the "-R" option, so there is a strong case for enabling it. #ls_recurse_enable=YES # # When "listen" directive is enabled, vsftpd runs in standalone mode and # listens on IPv4 sockets. This directive cannot be used in conjunction # with the listen_ipv6 directive. listen=YES # # This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6 # sockets, you must run two copies of vsftpd with two configuration files. # Make sure, that one of the listen options is commented !! #listen_ipv6=YES pam_service_name=vsftpd userlist_enable=YES //用戶列表中的用戶是否允許登錄FTP服務器,默認是不允許 tcp_wrappers=YES
(3)連接ftp服務器:
windows環境下:
Linux環境下:
1、連接ftp服務器:
格式:ftp [hostname| ip-address] a)在linux命令行下輸入: ftp 192.168.1.1 b)服務器詢問你用戶名和密碼,分別輸入用戶名和相應密碼,待認證通過即可。
2、下載文件
下載文件通常用get和mget這兩條命令。
a) get
格式:get [remote-file] [local-file]
將文件從遠端主機中傳送至本地主機中。
如要獲取遠程服務器上/usr/your/1.htm,則
get /usr/your/1.htm
b) mget
格式:mget [remote-files]
從遠端主機接收一批文件至本地主機。
如要獲取服務器上/usr/your/下的所有文件,則
ftp> cd /usr/your ftp> mget *.*
3、上傳文件
a) put
格式:put local-file [remote-file]
將本地一個文件傳送至遠端主機中。
如要把本地的1.htm傳送到遠端主機/usr/your,並改名爲2.htm
ftp> put 1.htm /usr/your/2.htm
b) mput
格式:mput local-files
將本地主機中一批文件傳送至遠端主機。
如要把本地當前目錄下所有html文件上傳到服務器/usr/your/ 下
ftp> cd /usr/your ftp> mput *.htm
4、斷開連接
ftp> bye