虛擬機的系統是centos6.3
第一步.啟動ftp
service vsftpd restart
提示 vsftpd: 未被識別的服務
解決方法是升級vsftpd服務
yum install vsftpd
再步重啟該服務成功.
netstat -an | grep 21
發現21端口確實處於LISTEN監聽狀態
第二步.
虛擬機使用命令
tcpdump -i eth0 -nnX port 21
用於抓取第一塊網卡ip的21端口數據包,以十六進制顯示
在真實機的命令行下使用命令(192.168.2.102為虛擬機的IP)
ftp 192.168.2.102
嘗試與虛擬機建立ftp連接
發現雖然虛擬機中能抓到包,但真實機並沒有提示輸入用戶名和密碼,即未成功連接
第三步.發現是iptables防火牆的問題.
servcie iptables stop
用於臨時關閉防火牆
chkconfig iptables off
用於永久關閉防火牆
第四步.執行第二步中的命令,需要輸入用戶名和密碼了.
但是之后立即提示
500 OOPS: cannot change directory:/home/user1 500 OOPS: child died 遠程主機關閉連接。
排查下列可能
- Does the directory for the user you are trying to login as even exist?
- Check file permissions for the directory being accessed to ensure that the directory can be read, but also has execute permissions.
- Check SELINUX. Might need to disable to get VSTFTPD to work. Not an ideal situation if you need SELINUX active, but at least you will know what the cause of your error is.
發現是SeLinux安全模塊的問題.
與SELinux有關的命令及文件:
查看SELinux狀態:
1、/usr/sbin/sestatus -v ##如果SELinux status參數為enabled即為開啟狀態
SELinux status: enabled
2、getenforce ##也可以用這個命令檢查
關閉SELinux:
1、臨時關閉(不用重啟機器):
setenforce 0 ##設置SELinux 成為permissive模式
##setenforce 1 設置SELinux 成為enforcing模式
2、修改配置文件需要重啟機器:
修改/etc/selinux/config 文件
將SELINUX=enforcing改為SELINUX=disabled
重啟機器即可
第五步.輸入成功,登錄成功