12月10日任務
14.4 exportfs命令
14.5 NFS客戶端問題
15.1 FTP介紹
15.2/15.3 使用vsftpd搭建ftplinux
1.exportfs命令vim
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
- exportfs 命令,
- 經常使用選項
- -a 所有掛載或者所有卸載
- -r 從新掛載
- -u 卸載某一個目錄
- -v 顯示共享目錄
- 如下操做在服務端上
- vim /etc/exports //增長
/tmp/ 192.168.133.0/24(rw,sync,no_root_squash) windows
![](http://static.javashuo.com/static/loading.gif)
- exportfs -arv //不用重啓nfs服務,配置文件就會生效,在服務端執行
- 以下是在客戶端執行的狀況
![](http://static.javashuo.com/static/loading.gif)
- 如下操做在客戶端
- mount -t nfs -onolock 192.168.133.130:/tmp /mnt 將目錄掛載到/mnt 下
![](http://static.javashuo.com/static/loading.gif)
- touch /mnt/test.txt 建立一個測試文件,隨便寫點內容
- ls -l !$ 查看一下文件詳細信息
- 在服務端的共享目錄裏,也能夠看到這個文件
- -oremount,nfsvers=3 未講解
2.NFS客戶端問題centos
![](http://static.javashuo.com/static/loading.gif)
- NFS 4版本會有該問題 ,尤爲是在centos 6 上使用會有這種問題
- 客戶端掛載共享目錄後,無論是root用戶仍是普通用戶,建立新文件時屬主、屬組爲nobody
- 客戶端掛載時加上 -o nfsvers=3 指定版本爲3
![](http://static.javashuo.com/static/loading.gif)
- 客戶端和服務端都須要 編輯這個文件
- vim /etc/idmapd.conf //
- 把「#Domain = local.domain.edu」 改成 「Domain = xxx.com」 (這裏的xxx.com,隨意定義吧),而後再重啓rpcidmapd服務
3.FTP介紹安全
![](http://static.javashuo.com/static/loading.gif)
- FTP是File Transfer Protocol(文件傳輸協議,簡稱文傳協議)的英文簡稱,用於在Internet上控制文件的雙向傳輸。
- FTP的主要做用就是讓用戶鏈接一個遠程計算機(這些計算機上運行着FTP服務器程序),並查看遠程計算機中的文件,而後把文件從遠程計算機複製到本地計算機,或把本地計算機的文件傳送到遠程計算機。
- 小公司用的多,大企業不用FTP,由於不安全
- 能夠將Windows的文件傳輸到服務器上
4.使用vsftpd搭建ftp服務器
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
示例一:session
- centos上自帶vsftpd
- yum install -y vsftpd 安裝該包
- useradd -s /sbin/nologin virftp 建立一個virftp用戶
- vim /etc/vsftpd/vsftpd_login //虛擬用戶的密碼文件,內容以下,奇數行爲用戶名,偶數行爲密碼,多個用戶就寫多行
testuser1dom
aminglinux1ssh
testuser2測試
aminglinux2
- chmod 600 /etc/vsftpd/vsftpd_login 設置權限600
- db_load -T -t hash -f /etc/vsftpd/vsftpd_login /etc/vsftpd/vsftpd_login.db 文本的密碼文件轉換成計算機識別的二進制文件
![](http://static.javashuo.com/static/loading.gif)
- mkdir /etc/vsftpd/vsftpd_user_conf 建立虛擬用戶的配置文件所在的目錄
- cd /etc/vsftpd/vsftpd_user_conf 進去到該目錄下
- vim testuser1 //建立一個虛擬用戶配置文件,加入以下內容
local_root=/home/virftp/testuser1 定義虛擬用戶的家目錄
anonymous_enable=NO 是否容許匿名用戶登陸
write_enable=YES 是否可寫
local_umask=022 定義建立新目錄和新文件的權限
anon_upload_enable=NO 是否容許匿名用戶上傳
anon_mkdir_write_enable=NO 是否容許匿名用戶建立目錄而且寫
idle_session_timeout=600 定義空閒會話超時
data_connection_timeout=120 定義數據鏈接超時
max_clients=10 定義最大的客戶端數
- mkdir /home/virftp/testuser1 建立虛擬用戶的家目錄
- touch /home/virftp/testuser1/aming.txt 建立一個測試文件
- chown -R virftp:virftp /home/virftp 更改權限
- vim /etc/pam.d/vsftpd //定義密碼文件在哪,在最前面加上
auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
- vim /etc/vsftpd/vsftpd.conf
- 將anonymous_enable=YES 改成 anonymous_enable=NO
- 將#anon_upload_enable=YES 改成 anon_upload_enable=NO
- 將#anon_mkdir_write_enable=YES
- 改成 anon_mkdir_write_enable=NO
- 在最下面,再增長以下內容
chroot_local_user=YES
guest_enable=YES
guest_username=virftp virtual_use_local_privs=YES
user_config_dir=/etc/vsftpd/vsftpd_user_conf
allow_writeable_chroot=YES 、
![](http://static.javashuo.com/static/loading.gif)
- systemctl start vsftpd //啓動vsftpd服務
- ps aux |grep vsftp 查看進程是否運行起來
![](http://static.javashuo.com/static/loading.gif)
- netstat -lntp 查看監聽的21端口是否監聽
![](http://static.javashuo.com/static/loading.gif)
- 21 端口監聽的是ftp
- 22 端口監聽的是ssh
- 23 端口監聽的是telnet
- 測試
- yum install -y lftp 安裝ftp客戶端服務軟件
- lftp testuser1 @127.0.0.1
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
- quit退出
- 若不正常查看日誌/var/log/messages和/var/log/secure
- windows下安裝filezilla客戶端軟件,進行測試