摘要:###################################### 訪問網(wǎng)絡(luò)文件系統(tǒng) ######################################Linux中有兩種主要協(xié)議可用來訪問網(wǎng)絡(luò)文件系統(tǒng):NFS和CIFSNFS(Network File System)可看作是Linux、UNIX及其它類似操作系統(tǒng)的標(biāo)準(zhǔn)文件系統(tǒng)CIF
###############################
####### 訪問網(wǎng)絡(luò)文件系統(tǒng) #######
###############################
Linux中有兩種主要協(xié)議可用來訪問網(wǎng)絡(luò)文件系統(tǒng):NFS和CIFS
NFS(Network File System)可看作是Linux、UNIX及其它類似操作系統(tǒng)的標(biāo)準(zhǔn)文件系統(tǒng)
CIFS(Comon Internet File System)則是針對Microsoft Windows系統(tǒng)的標(biāo)準(zhǔn)網(wǎng)絡(luò)文件系統(tǒng)
####################cifs網(wǎng)絡(luò)文件系統(tǒng)訪問####################
####################
在windows 7下開啟文件共享:
創(chuàng)建一個(gè)文件夾
右健點(diǎn)擊“屬性”,點(diǎn)擊“共享”選項(xiàng)卡,點(diǎn)擊“共享”
下拉列表選擇“Everyone”,點(diǎn)擊“添加”,選擇“讀/寫”權(quán)限,點(diǎn)擊“共享”,等待,點(diǎn)擊“完成”
使用win+r調(diào)出運(yùn)行窗口,輸入“\\ip地址”測試
注意:
到這里還沒有完,因?yàn)閣indows 7默認(rèn)不啟用“Guest”帳戶,并且默認(rèn)拒絕匿名用戶的訪問,所以還需要以下操作
1.打開“控制面板”,點(diǎn)擊“添加或刪除用戶賬戶”,點(diǎn)擊“Guest”帳戶,點(diǎn)擊“啟用”
2.使用win+r調(diào)出運(yùn)行窗口,輸入“gpedit.msc”,打開本地組策略編輯器。依次選擇“計(jì)算機(jī)配置-->Windows設(shè)置-->安全設(shè)置-->本地策略-->用戶權(quán)限分配”,雙擊“拒絕從網(wǎng)絡(luò)訪問這臺計(jì)算機(jī)”,刪除里面的“Guest”帳號,點(diǎn)擊“確定”。
(參考網(wǎng)址:https://zhidao.baidu.com/question/2052592758746862227.html)
####################
1.安裝共享訪問客戶端
yum install samba-client -y
2.識別共享服務(wù)器共享目錄
smbclient -L //172.25.254.253
[root@netfsclient mnt]# smbclient -L //172.25.254.253
直接回車
####################
[root@localhost ~]# smbclient -L //172.25.50.159 ##使用Guest用戶
Enter root's password:
Domain=[TEST-PC] OS=[Windows 7 Ultimate 7600] Server=[Windows 7 Ultimate 6.1]
Sharename Type Comment
--------- ---- -------
ADMIN$ Disk 遠(yuǎn)程管理
C$ Disk 默認(rèn)共享
D$ Disk 默認(rèn)共享
IPC$ IPC 遠(yuǎn)程 IPC
Users Disk
westos Disk
Connection to 172.25.50.159 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND)
NetBIOS over TCP disabled -- no workgroup available
[root@localhost ~]# smbclient -L //172.25.50.159 -U test%test ##使用本地用戶,"%"后面跟密碼
Domain=[TEST-PC] OS=[Windows 7 Ultimate 7600] Server=[Windows 7 Ultimate 6.1]
Sharename Type Comment
--------- ---- -------
ADMIN$ Disk 遠(yuǎn)程管理
C$ Disk 默認(rèn)共享
D$ Disk 默認(rèn)共享
IPC$ IPC 遠(yuǎn)程 IPC
Users Disk
westos Disk
Connection to 172.25.50.159 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND)
NetBIOS over TCP disabled -- no workgroup available
####################
3.訪問共享
命令訪問)
[root@netfsclient mnt]# smbclient //172.25.254.253/westos
####################
[root@localhost ~]# smbclient //172.25.50.159/westos
Enter root's password:
Domain=[TEST-PC] OS=[Windows 7 Ultimate 7600] Server=[Windows 7 Ultimate 6.1]
smb: \> pwd
Current directory is \\172.25.50.159\westos\
smb: \> ls
. D 0 Tue Nov 15 01:47:12 2016
.. D 0 Tue Nov 15 01:47:12 2016
40864 blocks of size 131072. 40863 blocks available
smb: \> !ls
anaconda-ks.cfg Documents Music Public Videos
Desktop Downloads Pictures Templates
smb: \> put anaconda-ks.cfg
putting file anaconda-ks.cfg as \anaconda-ks.cfg (25.9 kb/s) (average 25.9 kb/s)
smb: \> del anaconda-ks.cfg ##等同于"rm anaconda-ks.cfg"
>在win7的westos共享文件夾中創(chuàng)建123.txt
smb: \> ls
. D 0 Tue Nov 15 01:47:12 2016
.. D 0 Tue Nov 15 01:47:12 2016
123.txt A 0 Tue Nov 15 02:44:54 2016
40864 blocks of size 131072. 40863 blocks available
smb: \> get 123.txt
getting file \123.txt of size 0 as 123.txt (0.0 KiloBytes/sec) (average 0.0 KiloBytes/sec)
smb: \> !ls
123.txt Desktop Downloads Pictures Templates
anaconda-ks.cfg Documents Music Public Videos
smb: \> exit
[root@localhost ~]#
####################
掛載訪問)
mount //172.25.254.253/westos /mnt -o username=guest
####################
[root@localhost ~]# mount //172.25.254.253/westos /mnt
mount: wrong fs type, bad option, bad superblock on //172.25.254.253/westos,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount.<type> helper program)
In some cases useful info is found in syslog - try
dmesg | tail or so.
##失敗原因是linux的匿名用戶不是Guest
[root@localhost ~]# mount //172.25.50.159/westos /mnt -o username=guest
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3157404 7316496 31% /
devtmpfs 493408 0 493408 0% /dev
tmpfs 508996 80 508916 1% /dev/shm
tmpfs 508996 13344 495652 3% /run
tmpfs 508996 0 508996 0% /sys/fs/cgroup
//172.25.50.159/westos 5230592 16 5230576 1% /mnt
[root@localhost ~]# mount //172.25.50.159/westos /mnt -o username=guest
[root@localhost ~]# cd /mnt
[root@localhost mnt]# ls
123.txt
[root@localhost mnt]# touch file{1..3}
[root@localhost mnt]# ls
123.txt file1 file2 file3
[root@localhost mnt]# rm -fr *
[root@localhost mnt]# ls
[root@localhost mnt]# cd
[root@localhost ~]# umount /mnt
####################
4.開機(jī)自動(dòng)掛載cifs
方法1)
vim /etc/fstab
//172.25.254.253/westos /mnt cifs defaults,username=guest 0 0
####################
[root@localhost ~]# vim /etc/fstab
--------------------------------------------------
添加:
//172.25.50.159/westos /mnt cifs defaults,username=guest 0 0
:wq
--------------------------------------------------
[root@localhost ~]# mount -a
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3157452 7316448 31% /
devtmpfs 493408 0 493408 0% /dev
tmpfs 508996 80 508916 1% /dev/shm
tmpfs 508996 13372 495624 3% /run
tmpfs 508996 0 508996 0% /sys/fs/cgroup
//172.25.50.159/westos 5230592 16 5230576 1% /mnt
####################
方法2)
vim /etc/rc.d/rc.local
mount //172.25.254.253/westos /mnt/ -o username=guest
chmod 755 /etc/rc.d/rc.local
建議寫道rc.local,如果寫到fstab,一旦寫錯(cuò)就導(dǎo)致系統(tǒng)啟不起來
####################
[root@localhost ~]# vim /etc/rc.d/rc.local
--------------------------------------------------
添加:
mount //172.25.50.159/westos /mnt/ -o username=guest
:wq
--------------------------------------------------
[root@localhost ~]# ll /etc/rc.d/rc.local
-rw-r--r--. 1 root root 2655 Nov 15 03:23 /etc/rc.d/rc.local
[root@localhost ~]# chmod 755 /etc/rc.d/rc.local
[root@localhost ~]# ll /etc/rc.d/rc.local
-rwxr-xr-x. 1 root root 2708 Nov 15 03:51 /etc/rc.d/rc.local
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3157460 7316440 31% /
devtmpfs 493408 0 493408 0% /dev
tmpfs 508996 80 508916 1% /dev/shm
tmpfs 508996 13372 495624 3% /run
tmpfs 508996 0 508996 0% /sys/fs/cgroup
[root@localhost ~]# sh /etc/rc.d/rc.local
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3157460 7316440 31% /
devtmpfs 493408 0 493408 0% /dev
tmpfs 508996 80 508916 1% /dev/shm
tmpfs 508996 13372 495624 3% /run
tmpfs 508996 0 508996 0% /sys/fs/cgroup
//172.25.50.159/westos 5230592 16 5230576 1% /mnt
####################
####################nfs網(wǎng)絡(luò)文件系統(tǒng)的訪問####################
nfs-utils客戶端和服務(wù)端一樣,類似chronyd
####################
服務(wù)端:
[root@localhost ~]# mkdir -p /nfsshare/nfs{1..5}
[root@localhost ~]# yum install nfs-utils -y
[root@localhost ~]# vim /etc/exports
--------------------------------------------------
/nfsshare/nfs1 *(rw,no_root_squash)
/nfsshare/nfs2 *(rw,no_root_squash)
/nfsshare/nfs3 *(rw,no_root_squash)
/nfsshare/nfs4 *(rw,no_root_squash)
/nfsshare/nfs5 *(rw,no_root_squash)
:wq
--------------------------------------------------
##"no_root_squash"表示不將root用戶及所屬用戶組映射為匿名用戶或匿名用戶組,默認(rèn)root是被映射為匿名用戶的
[root@localhost ~]# exportfs -rv
exporting *:/nfsshare/nfs5
exporting *:/nfsshare/nfs4
exporting *:/nfsshare/nfs3
exporting *:/nfsshare/nfs2
exporting *:/nfsshare/nfs1
[root@localhost ~]# systemctl start nfs-server
[root@localhost ~]# systemctl enable nfs-server
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service
####################
1.安裝訪問共享軟件
yum install nfs-utils -y
2.識別共享
showmount -e 172.25.254.250
####################
[root@localhost ~]# showmount -e 172.25.50.100
Export list for 172.25.50.100:
/nfsshare/nfs5 *
/nfsshare/nfs4 *
/nfsshare/nfs3 *
/nfsshare/nfs2 *
/nfsshare/nfs1 *
####################
3.使用共享
mount 172.25.254.250:/nfsshare/nfs1 /mnt
####################
[root@localhost ~]# mount 172.25.50.100:/nfsshare/nfs1 /mnt
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3159128 7314772 31% /
devtmpfs 493408 0 493408 0% /dev
tmpfs 508996 80 508916 1% /dev/shm
tmpfs 508996 13348 495648 3% /run
tmpfs 508996 0 508996 0% /sys/fs/cgroup
172.25.50.100:/nfsshare/nfs1 10473984 3159168 7314816 31% /mnt
[root@localhost ~]# cd /mnt
[root@localhost mnt]# touch 123
[root@localhost mnt]# ls
123
[root@localhost mnt]# ls /nfsshare/nfs1/
123
####################
4.自動(dòng)掛載
方法1)
vim /etc/fstab
172.25.254.250:/nfsshare/nfs1 /mnt nfs defaults 0 0
方法2)
vim /etc/rc.d/rc.local
mount 172.25.254.250:/nfsshare/nfs1 /mnt
chmod 755 /etc/rc.d/rc.local
####################autofs自動(dòng)掛載服務(wù)####################
1.服務(wù)功能
默認(rèn)情況下,使用mount掛載共享
在不使用共享時(shí)也會(huì)處于掛載狀態(tài),浪費(fèi)共享服務(wù)器的資源
autofs可以實(shí)現(xiàn)當(dāng)使用時(shí)自動(dòng)掛載,當(dāng)閑置時(shí)自動(dòng)卸載
2.安裝服務(wù)
yum install autofs -y
systemctl start autofs
####################
[root@localhost ~]# ll /net
ls: cannot access /net: No such file or directory
[root@localhost ~]# systemctl start autofs
[root@localhost ~]# ll /net
total 0
[root@localhost ~]# ll -d /net
drwxr-xr-x. 2 root root 0 Nov 15 20:36 /net
####################
3.訪問
cd /net/172.25.254.250/nfsshare/nfs1
####################
[root@localhost ~]# cd /net/172.25.50.100/nfsshare/nfs1
[root@localhost nfs1]# ls
123
[root@localhost nfs1]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3174544 7299356 31% /
devtmpfs 493408 0 493408 0% /dev
tmpfs 508996 84 508912 1% /dev/shm
tmpfs 508996 13368 495628 3% /run
tmpfs 508996 0 508996 0% /sys/fs/cgroup
/dev/vda1 10473900 3174544 7299356 31% /net/172.25.50.100/nfsshare/nfs1
>發(fā)現(xiàn)掛載設(shè)備是/dev/vda1。由于服務(wù)端和客戶端都是desktop,效果不太好,打開虛擬機(jī)server進(jìn)行測試。
server:
[root@localhost ~]# showmount -e 172.25.50.100 ##輸出省略
[root@localhost ~]# vim /etc/yum.repos.d/rhel_dvd.repo ##輸出省略
[root@localhost ~]# yum install autofs -y ##輸出省略
[root@localhost ~]# systemctl start autofs
[root@localhost ~]# cd /net/172.25.50.100/nfsshare/nfs1
[root@localhost nfs1]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3149760 7324140 31% /
devtmpfs 493408 0 493408 0% /dev
tmpfs 508996 84 508912 1% /dev/shm
tmpfs 508996 13368 495628 3% /run
tmpfs 508996 0 508996 0% /sys/fs/cgroup
172.25.50.100:/nfsshare/nfs1 10473984 3174656 7299328 31% /net/172.25.50.100/nfsshare/nfs1
[root@localhost nfs1]# cd
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3149760 7324140 31% /
devtmpfs 493408 0 493408 0% /dev
tmpfs 508996 84 508912 1% /dev/shm
tmpfs 508996 13368 495628 3% /run
tmpfs 508996 0 508996 0% /sys/fs/cgroup
172.25.50.100:/nfsshare/nfs1 10473984 3174656 7299328 31% /net/172.25.50.100/nfsshare/nfs1
####################
4.設(shè)定空閑卸載時(shí)間
vim /etc/autofs.conf
15 timeout = 3 ##閑置3秒后系統(tǒng)自動(dòng)卸載網(wǎng)絡(luò)設(shè)備
systemctl restart autofs
autofs默認(rèn)退出等待時(shí)間是300秒,只針對nfs
####################
server:
[root@localhost ~]# vim /etc/sysconfig/autofs
--------------------------------------------------
將第13行
13 TIMEOUT=300
修改為
13 TIMEOUT=3
:wq
--------------------------------------------------
[root@localhost ~]# systemctl restart autofs.service
[root@localhost ~]# cd /net/172.25.50.100/nfsshare/nfs1
[root@localhost nfs1]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3149764 7324136 31% /
devtmpfs 493408 0 493408 0% /dev
tmpfs 508996 84 508912 1% /dev/shm
tmpfs 508996 13368 495628 3% /run
tmpfs 508996 0 508996 0% /sys/fs/cgroup
172.25.50.100:/nfsshare/nfs1 10473984 3174656 7299328 31% /net/172.25.50.100/nfsshare/nfs1
[root@localhost nfs1]# cd
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3149764 7324136 31% /
devtmpfs 493408 0 493408 0% /dev
tmpfs 508996 84 508912 1% /dev/shm
tmpfs 508996 13368 495628 3% /run
tmpfs 508996 0 508996 0% /sys/fs/cgroup
####################
5.實(shí)現(xiàn)自定義共享掛載點(diǎn)
vim /etc/auto.master
最終自定義掛載點(diǎn)的上層目錄 子配置文件
/mnt /etc/auto.nfs
vim子配置文件
最終掛載點(diǎn) 網(wǎng)絡(luò)共享目錄
vim /etc/auto.nfs
pub1 172.25.254.250:/nfsshare/nfs1
* 172.25.254.250:/nfsshare& ##指定任意共享掛載
systemctl restart autofs
####################
server:
[root@localhost ~]# vim /etc/auto.master
--------------------------------------------------
13 /net -hosts
在13行下面插入一行
14 /mnt /etc/auto.nfs
:wq
--------------------------------------------------
[root@localhost ~]# ll /etc/auot.nfs
ls: cannot access /etc/auot.nfs: No such file or directory
[root@localhost ~]# vim /etc/auto.nfs
--------------------------------------------------
pub1 172.25.50.100:/nfsshare/nfs1
:wq
--------------------------------------------------
[root@localhost ~]# systemctl restart autofs.service
[root@localhost ~]# cd /mnt
[root@localhost mnt]# ls
[root@localhost mnt]# cd pub1
[root@localhost pub1]# ls
123
[root@localhost pub1]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3149840 7324060 31% /
devtmpfs 493408 0 493408 0% /dev
tmpfs 508996 84 508912 1% /dev/shm
tmpfs 508996 13368 495628 3% /run
tmpfs 508996 0 508996 0% /sys/fs/cgroup
172.25.50.100:/nfsshare/nfs1 10473984 3174656 7299328 31% /mnt/pub1
[root@localhost pub1]# cd
[root@localhost ~]# vim /etc/auto.nfs
--------------------------------------------------
* 172.25.50.100:/nfsshare/&
:wq
--------------------------------------------------
[root@localhost ~]# systemctl restart autofs.service
[root@localhost ~]# cd /mnt
[root@localhost mnt]# ls
[root@localhost mnt]# cd nfs1
[root@localhost nfs1]# ls
123
[root@localhost nfs1]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3149848 7324052 31% /
devtmpfs 493408 0 493408 0% /dev
tmpfs 508996 84 508912 1% /dev/shm
tmpfs 508996 13396 495600 3% /run
tmpfs 508996 0 508996 0% /sys/fs/cgroup
172.25.50.100:/nfsshare/nfs1 10473984 3174784 7299200 31% /mnt/nfs1
[root@localhost nfs3]# cd /mnt/nfs2
[root@localhost nfs2]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3149848 7324052 31% /
devtmpfs 493408 0 493408 0% /dev
tmpfs 508996 84 508912 1% /dev/shm
tmpfs 508996 13396 495600 3% /run
tmpfs 508996 0 508996 0% /sys/fs/cgroup
172.25.50.100:/nfsshare/nfs1 10473984 3174656 7299328 31% /mnt/nfs1
[root@localhost nfs2]# ls
[root@localhost nfs2]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 10473900 3149848 7324052 31% /
devtmpfs 493408 0 493408 0% /dev
tmpfs 508996 84 508912 1% /dev/shm
tmpfs 508996 13396 495600 3% /run
tmpfs 508996 0 508996 0% /sys/fs/cgroup
172.25.50.100:/nfsshare/nfs2 10473984 3174656 7299328 31% /mnt/nfs2
####################
####################
#### vsftpd服務(wù) ####
####################
1.什么是ftp
2.安裝ftp
yum install vsftpd -y
systemctl start vsftpd
systemctl stop firewalld
systemctl enable vsftpd
setenforce 0
lftp ip ##能登陸并且顯示,表示安裝成功
3.vsftpd文件信息
/var/ftp ##默認(rèn)發(fā)布目錄
/etc/vsftpd ##配置目錄
4.vsftpd服務(wù)的配置參數(shù)
1)匿名用戶設(shè)定
anonymous_enable=YES|NO ##匿名用戶登陸限制
#<匿名用戶上傳>
vim /etc/vsftpd/vsftpd.conf
write_enable=YES
anon_upload_enable=YES
chgrp ftp /var/ftp/pub
chmod 775 /var/ftp/pub
#<匿名用戶家目錄修改>
anon_root=/direcotry
#<匿名用戶上傳文件默認(rèn)權(quán)限修改>
anon_umask=xxx
#<匿名用戶建立目錄>
anon_mkdir_write_enable=YES|NO
#<匿名用戶下載>
anon_world_readable_only=YES|NO ##設(shè)定參數(shù)值為no表示匿名用戶可以下載
#<匿名用戶刪除>
anon_other_write_enable=YES|NO
####################
服務(wù)端:
[root@server ~]# yum install vsftpd -y
......
[root@server ~]# systemctl start vsftpd
[root@server ~]# systemctl enable vsftpd
[root@server ~]# firewall-cmd --list-all
public (default, active)
interfaces: eth0
sources:
services: dhcpv6-client ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
[root@server ~]# firewall-cmd --permanent --add-service=ftp
success
[root@server ~]# firewall-cmd --reload
success
[root@server ~]# firewall-cmd --list-all
public (default, active)
interfaces: eth0
sources:
services: dhcpv6-client ftp ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
客戶端:
[root@desktop ~]# yum install lftp -y
......
[root@desktop ~]# lftp 172.25.50.200
lftp 172.25.50.200:~> ls
drwxr-xr-x 2 0 0 6 Mar 07 2014 pub
lftp 172.25.50.200:~> cd pub/
cd ok, cwd=/pub
lftp 172.25.50.200:/pub> ls
服務(wù)端:
[root@server ~]# cd /var/ftp/pub
[root@server pub]# ls
[root@server pub]# touch file{1..3}
客戶端:
lftp 172.25.50.200:/pub> ls
-rw-r--r-- 1 0 0 0 Nov 16 09:24 file1
-rw-r--r-- 1 0 0 0 Nov 16 09:24 file2
-rw-r--r-- 1 0 0 0 Nov 16 09:24 file3
lftp 172.25.50.200:~> exit
服務(wù)端:
[root@server pub]# rpm -qc vsftpd
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
[root@server pub]# vim /etc/vsftpd/vsftpd.conf
--------------------------------------------------
12 anonymous_enable=NO
:wq
--------------------------------------------------
[root@server pub]# systemctl restart vsftpd
客戶端:
[root@desktop ~]# lftp 172.25.50.200
lftp 172.25.50.200:~> ls
Interrupt
lftp 172.25.50.200:~> exit
[root@desktop ~]#
服務(wù)端:
[root@server pub]# vim /etc/vsftpd/vsftpd.conf
--------------------------------------------------
12 anonymous_enable=YES
29 anon_upload_enable=YES
:wq
--------------------------------------------------
[root@server pub]# systemctl restart vsftpd
客戶端:
[root@desktop ~]# lftp 172.25.50.200
lftp 172.25.50.200:~> ls
drwxr-xr-x 2 0 0 42 Nov 16 09:24 pub
lftp 172.25.50.200:/> cd pub/
lftp 172.25.50.200:/pub> ls
-rw-r--r-- 1 0 0 0 Nov 16 09:24 file1
-rw-r--r-- 1 0 0 0 Nov 16 09:24 file2
-rw-r--r-- 1 0 0 0 Nov 16 09:24 file3
lftp 172.25.50.200:/pub> put /etc/passwd
put: Access failed: 553 Could not create file. (passwd)
服務(wù)端:
[root@server pub]# ll /var/ftp
total 0
drwxr-xr-x. 2 root root 42 Nov 16 04:24 pub
[root@server pub]# chmod 777 /var/ftp/pub
[root@server pub]# ll /var/ftp
total 0
drwxrwxrwx. 2 root root 42 Nov 16 04:24 pub
客戶端:
lftp 172.25.50.200:/pub> put /etc/passwd
put: Access failed: 553 Could not create file. (passwd)
服務(wù)端:
[root@server pub]# setenforce 0 ##selinux警告模式;"setenforce 1"selinux禁止模式
[root@server pub]# getenforce
Permissive
客戶端:
lftp 172.25.50.200:/pub> put /etc/passwd
2005 bytes transferred
lftp 172.25.50.200:/pub> ls
-rw-r--r-- 1 0 0 0 Nov 16 09:24 file1
-rw-r--r-- 1 0 0 0 Nov 16 09:24 file2
-rw-r--r-- 1 0 0 0 Nov 16 09:24 file3
-rw------- 1 14 50 2005 Nov 16 09:57 passwd
服務(wù)端:
[root@server pub]# chgrp ftp /var/ftp/pub/
[root@server pub]# chmod 775 /var/ftp/pub/
[root@server pub]# ll /var/ftp/
total 0
drwxrwxr-x. 2 root ftp 55 Nov 16 04:57 pub
客戶端:
lftp 172.25.50.200:/pub> get passwd
get: Access failed: 550 Failed to open file. (passwd)
服務(wù)端:
[root@server pub]# man 5 vsftpd.conf
--------------------------------------------------
anon_world_readable_only
When enabled, anonymous users will only be allowed to download
files which are world readable. This is recognising that the ftp
user may own files, especially in the presence of uploads.
Default: YES
--------------------------------------------------
[root@server pub]# vim /etc/vsftpd/vsftpd.conf
--------------------------------------------------
30 anon_world_readable_only=NO
:wq
--------------------------------------------------
[root@server pub]# systemctl restart vsftpd
客戶端:
lftp 172.25.50.200:/pub> get passwd
2005 bytes transferred
lftp 172.25.50.200:/pub> !ls
anaconda-ks.cfg Documents Music Pictures Templates
Desktop Downloads passwd Public Videos
lftp 172.25.50.200:/pub> mkdir westos
mkdir: Access failed: 550 Permission denied. (westos)
服務(wù)端:
[root@server pub]# man 5 vsftpd.conf
--------------------------------------------------
anon_mkdir_write_enable
If set to YES, anonymous users will be permitted to create new
directories under certain conditions. For this to work, the
option write_enable must be activated, and the anonymous ftp
user must have write permission on the parent directory.
Default: NO
--------------------------------------------------
[root@server pub]# vim /etc/vsftpd/vsftpd.conf
--------------------------------------------------
34 anon_mkdir_write_enable=YES
:wq
--------------------------------------------------
[root@server pub]# systemctl restart vsftpd
客戶端:
lftp 172.25.50.200:/pub> mkdir westos
mkdir ok, `westos' created
lftp 172.25.50.200:/pub> ls
-rw-r--r-- 1 0 0 0 Nov 16 09:24 file1
-rw-r--r-- 1 0 0 0 Nov 16 09:24 file2
-rw-r--r-- 1 0 0 0 Nov 16 09:24 file3