ftp簡單操做及解說

一.實驗拓撲vim

服務器 ------------------------客戶機服務器

二.實驗條件tcp

  1. 試驗機在同一個網段,能夠互相ping通。ide

  2. 肯定裝在了ftp軟件包。測試

三.實驗一:ui

匿名用戶與本地用戶均可以登陸spa

匿名用戶登陸到/var/ftp,只能下載不能上傳rest

本地用戶登陸到本地用戶的家目錄,能夠上傳和下載ip

  1. 實驗步驟;ci

[root@localhost ~]# rpm -q vsftp              //檢測是否安裝軟件        

package vsftp is not installed                      //表明沒有安裝的意思

[root@localhost ~]# cd /misc/cd/Server/             //切換到掛載的光盤目錄

[root@localhost Server]# ls *vsftp*                   //查找 ftp軟件的全稱

vsftpd-2.0.5-28.el5.x86_64.rpm                    //ftp軟件的全稱

[root@localhost Server]# rpm -ivh vsftpd-2.0.5-28.el5.x86_64.rpm         //安裝該軟件

[root@localhost Server]# rpm -q vsftpd

vsftpd-2.0.5-28.el5                                       //再次檢查出現這個表明此電腦安裝的此程序

[root@localhost Server]# service vsftpd restart                         //重啓該服務

[root@localhost Server]# chkconfig on                             //開啓服務

[root@localhost Server]# ls -lh /etc > /var/ftp/pub/etc.txt           //etc 重定向/pub/etc.txt

[root@localhost ~]# useradd kaka                    //建立用戶kaka

[root@localhost ~]# echo "123456" | passwd --stdin kaka        //設置kaka的密碼,這種設置密碼是我知道中用的最多的不用重複密碼的肯定。

  1. 驗證:

[root@localhost root]# ftp 192.168.4.5     //進入服務器的ftp 後面是服務器的ip地址

Connected to 192.168.4.5.

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 (192.168.4.5:root): ftp                //匿名用戶輸入ftp ,不匿名用戶輸入用用戶名

331 Please specify the password.

Password:                                   //匿名用戶不用輸入密碼直接回車,不匿名用戶輸入密碼

230 Login successful.

Remote system type is UNIX.

Using binary mode to transfer files.

ftp> pwd                       //顯示本身的所在位置

257 "/"                           //位置

ftp> ls                              //查看

227 Entering Passive Mode (192,168,4,5,253,103)

150 Here comes the directory listing.

drwxr-xr-x    2 0        0            4096 Jun 15 04:50 pub

226 Directory send OK.

ftp> cd pub                          //切換到pub

250 Directory successfully changed.

ftp> ls                            //查看

227 Entering Passive Mode (192,168,4,5,177,250)

150 Here comes the directory listing.

-rw-r--r--    1 0        0           12095 Jun 15 04:50 etc.txt   //服務器上的重定向文件

226 Directory send OK.

ftp> get etc.txt                             //下載該文件

local: etc.txt remote: etc.txt

227 Entering Passive Mode (192,168,4,5,190,138)

150 Opening BINARY mode data connection for etc.txt (12095 bytes).

226 File send OK.

12095 bytes received in 0.0054 seconds (2.2e+03 Kbytes/s)

ftp> !ls                           //「!ls 」中間沒有空格,在ftp裏查看本機的目錄

anaconda-ks.cfg  Desktop  etc.txt  install.log  install.log.syslog  root.txt 

ftp> put root.txt      //上傳該文件

local: root.txt remote: root.txt

227 Entering Passive Mode (192,168,4,5,229,92)

550 Permission denied.                //該三段話表明上傳失敗

ftp> quit                           //退出ftp

切換到kaka用戶登陸ftp

ftp> put root.txt                 //上傳文件

local: root.txt remote: root.txt

227 Entering Passive Mode (192,168,4,5,126,144)

150 Ok to send data.

226 File receive OK.                 //表明上傳成功

ftp> ls                                //查看剛纔上傳的文件

227 Entering Passive Mode (192,168,4,5,225,184)

150 Here comes the directory listing.

-rw-r--r--    1 501      501             0 Jun 15 05:11 root.txt

226 Directory send OK.

四.實驗二

         禁止匿名用戶登陸

         修改FTP默認端口爲2121

         禁錮本地用戶在本身家目錄

  1. 實驗步驟:

服務器上的配置:

[root@tarena ~]# cd /etc/vsftpd/            //切換到該目錄下

[root@tarena vsftpd]# ls

ftpusers  user_list  vsftpd.conf  vsftpd_conf_migrate.sh

[root@tarena vsftpd]# cp vsftpd.conf vsftpd.conf.txt      //複製備份該配置文件以防本身修改錯誤

[root@tarena vsftpd]# vim vsftpd.conf

12 anonymous_enable=NO            //修改裏面的內容這條是靜止匿名用戶登陸,默認是YES也就是贊成匿名用戶登陸

...

119 listen_port=2121                         //端口號修改

120 chroot_local_user=YES                    //是否禁錮在主目錄也就是本身家的目錄

[root@tarena vsftpd]# service vsftpd restart          //重啓該服務

[root@tarena vsftpd]# netstat -tulnp | grep vsftpd

tcp        0      0 0.0.0.0:2121                0.0.0.0:*                   LISTEN      13059/vsftpd           //查看端口號是否改變

2 .測試:

客戶機的測試

[root@localhost root]# ftp 192.168.4.5      //在修改端口號後登陸ftp

ftp: connect: Connection refused      //報錯提示  端口號報錯

ftp> pwd

Not connected.                   //報錯

[root@localhost root]# ftp 192.168.4.5 2121   //後面加上修改的端口號

Connected to 192.168.4.5.

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 (192.168.4.5:root): ftp          //匿名用戶登陸

331 Please specify the password.

Password:                   //匿名用戶不用密碼直接回車

530 Login incorrect.

Login failed.

ftp> pwd                   

530 Please login with USER and PASS.                   //報錯

 

[root@localhost root]# ftp 192.168.4.5 2121

Connected to 192.168.4.5.

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 (192.168.4.5:root): kaka                 //輸入用戶名

331 Please specify the password.

Password:                            //密碼

230 Login successful.

Remote system type is UNIX.

Using binary mode to transfer files.           //這三段表明登陸成功

相關文章
相關標籤/搜索