Linux课程第十五天学习笔记
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux课程第十五天学习笔记相关的知识,希望对你有一定的参考价值。
###############################
####### 访问网络文件系统 #######
###############################
Linux中有两种主要协议可用来访问网络文件系统:NFS和CIFS
NFS(Network File System)可看作是Linux、UNIX及其它类似操作系统的标准文件系统
CIFS(Comon Internet File System)则是针对Microsoft Windows系统的标准网络文件系统
####################cifs网络文件系统访问####################
####################
在windows 7下开启文件共享:
创建一个文件夹
右健点击“属性”,点击“共享”选项卡,点击“共享”
下拉列表选择“Everyone”,点击“添加”,选择“读/写”权限,点击“共享”,等待,点击“完成”
使用win+r调出运行窗口,输入“\\ip地址”测试
注意:
到这里还没有完,因为windows 7默认不启用“Guest”帐户,并且默认拒绝匿名用户的访问,所以还需要以下操作
1.打开“控制面板”,点击“添加或删除用户账户”,点击“Guest”帐户,点击“启用”
2.使用win+r调出运行窗口,输入“gpedit.msc”,打开本地组策略编辑器。依次选择“计算机配置-->Windows设置-->安全设置-->本地策略-->用户权限分配”,双击“拒绝从网络访问这台计算机”,删除里面的“Guest”帐号,点击“确定”。
(参考网址:https://zhidao.baidu.com/question/2052592758746862227.html)
####################
1.安装共享访问客户端
yum install samba-client -y
2.识别共享服务器共享目录
smbclient -L //172.25.254.253
[[email protected] mnt]# smbclient -L //172.25.254.253
直接回车
####################
[[email protected] ~]# 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 远程管理
C$ Disk 默认共享
D$ Disk 默认共享
IPC$ IPC 远程 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
[[email protected] ~]# 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 远程管理
C$ Disk 默认共享
D$ Disk 默认共享
IPC$ IPC 远程 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.访问共享
命令访问)
[[email protected] mnt]# smbclient //172.25.254.253/westos
####################
[[email protected] ~]# 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共享文件夹中创建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
[[email protected] ~]#
####################
挂载访问)
mount //172.25.254.253/westos /mnt -o username=guest
####################
[[email protected] ~]# 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
[[email protected] ~]# mount //172.25.50.159/westos /mnt -o username=guest
[[email protected] ~]# 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
[[email protected] ~]# mount //172.25.50.159/westos /mnt -o username=guest
[[email protected] ~]# cd /mnt
[[email protected] mnt]# ls
123.txt
[[email protected] mnt]# touch file{1..3}
[[email protected] mnt]# ls
123.txt file1 file2 file3
[[email protected] mnt]# rm -fr *
[[email protected] mnt]# ls
[[email protected] mnt]# cd
[[email protected] ~]# umount /mnt
####################
4.开机自动挂载cifs
方法1)
vim /etc/fstab
//172.25.254.253/westos /mnt cifs defaults,username=guest 0 0
####################
[[email protected] ~]# vim /etc/fstab
--------------------------------------------------
添加:
//172.25.50.159/westos /mnt cifs defaults,username=guest 0 0
:wq
--------------------------------------------------
[[email protected] ~]# mount -a
[[email protected] ~]# 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,一旦写错就导致系统启不起来
####################
[[email protected] ~]# vim /etc/rc.d/rc.local
--------------------------------------------------
添加:
mount //172.25.50.159/westos /mnt/ -o username=guest
:wq
--------------------------------------------------
[[email protected] ~]# ll /etc/rc.d/rc.local
-rw-r--r--. 1 root root 2655 Nov 15 03:23 /etc/rc.d/rc.local
[[email protected] ~]# chmod 755 /etc/rc.d/rc.local
[[email protected] ~]# ll /etc/rc.d/rc.local
-rwxr-xr-x. 1 root root 2708 Nov 15 03:51 /etc/rc.d/rc.local
[[email protected] ~]# 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
[[email protected] ~]# sh /etc/rc.d/rc.local
[[email protected] ~]# 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网络文件系统的访问####################
nfs-utils客户端和服务端一样,类似chronyd
####################
服务端:
[[email protected] ~]# mkdir -p /nfsshare/nfs{1..5}
[[email protected] ~]# yum install nfs-utils -y
[[email protected] ~]# 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用户及所属用户组映射为匿名用户或匿名用户组,默认root是被映射为匿名用户的
[[email protected] ~]# exportfs -rv
exporting *:/nfsshare/nfs5
exporting *:/nfsshare/nfs4
exporting *:/nfsshare/nfs3
exporting *:/nfsshare/nfs2
exporting *:/nfsshare/nfs1
[[email protected] ~]# systemctl start nfs-server
[[email protected] ~]# systemctl enable nfs-server
[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# systemctl disable firewalld.service
####################
1.安装访问共享软件
yum install nfs-utils -y
2.识别共享
showmount -e 172.25.254.250
####################
[[email protected] ~]# 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
####################
[[email protected] ~]# mount 172.25.50.100:/nfsshare/nfs1 /mnt
[[email protected] ~]# 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
[[email protected] ~]# cd /mnt
[[email protected] mnt]# touch 123
[[email protected] mnt]# ls
123
[[email protected] mnt]# ls /nfsshare/nfs1/
123
####################
4.自动挂载
方法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自动挂载服务####################
1.服务功能
默认情况下,使用mount挂载共享
在不使用共享时也会处于挂载状态,浪费共享服务器的资源
autofs可以实现当使用时自动挂载,当闲置时自动卸载
2.安装服务
yum install autofs -y
systemctl start autofs
####################
[[email protected] ~]# ll /net
ls: cannot access /net: No such file or directory
[[email protected] ~]# systemctl start autofs
[[email protected] ~]# ll /net
total 0
[[email protected] ~]# ll -d /net
drwxr-xr-x. 2 root root 0 Nov 15 20:36 /net
####################
3.访问
cd /net/172.25.254.250/nfsshare/nfs1
####################
[[email protected] ~]# cd /net/172.25.50.100/nfsshare/nfs1
[[email protected] nfs1]# ls
123
[[email protected] 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
>发现挂载设备是/dev/vda1。由于服务端和客户端都是desktop,效果不太好,打开虚拟机server进行测试。
server:
[[email protected] ~]# showmount -e 172.25.50.100 ##输出省略
[[email protected] ~]# vim /etc/yum.repos.d/rhel_dvd.repo ##输出省略
[[email protected] ~]# yum install autofs -y ##输出省略
[[email protected] ~]# systemctl start autofs
[[email protected] ~]# cd /net/172.25.50.100/nfsshare/nfs1
[[email protected] 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
[[email protected] nfs1]# cd
[[email protected] ~]# 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.设定空闲卸载时间
vim /etc/autofs.conf
15 timeout = 3 ##闲置3秒后系统自动卸载网络设备
systemctl restart autofs
autofs默认退出等待时间是300秒,只针对nfs
####################
server:
[[email protected] ~]# vim /etc/sysconfig/autofs
--------------------------------------------------
将第13行
13 TIMEOUT=300
修改为
13 TIMEOUT=3
:wq
--------------------------------------------------
[[email protected] ~]# systemctl restart autofs.service
[[email protected] ~]# cd /net/172.25.50.100/nfsshare/nfs1
[[email protected] 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
[[email protected] nfs1]# cd
[[email protected] ~]# 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.实现自定义共享挂载点
vim /etc/auto.master
最终自定义挂载点的上层目录 子配置文件
/mnt /etc/auto.nfs
vim子配置文件
最终挂载点 网络共享目录
vim /etc/auto.nfs
pub1 172.25.254.250:/nfsshare/nfs1
* 172.25.254.250:/nfsshare& ##指定任意共享挂载
systemctl restart autofs
####################
server:
[[email protected] ~]# vim /etc/auto.master
--------------------------------------------------
13 /net -hosts
在13行下面插入一行
14 /mnt /etc/auto.nfs
:wq
--------------------------------------------------
[[email protected] ~]# ll /etc/auot.nfs
ls: cannot access /etc/auot.nfs: No such file or directory
[[email protected] ~]# vim /etc/auto.nfs
--------------------------------------------------
pub1 172.25.50.100:/nfsshare/nfs1
:wq
--------------------------------------------------
[[email protected] ~]# systemctl restart autofs.service
[[email protected] ~]# cd /mnt
[[email protected] mnt]# ls
[[email protected] mnt]# cd pub1
[[email protected] pub1]# ls
123
[[email protected] 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
[[email protected] pub1]# cd
[[email protected] ~]# vim /etc/auto.nfs
--------------------------------------------------
* 172.25.50.100:/nfsshare/&
:wq
--------------------------------------------------
[[email protected] ~]# systemctl restart autofs.service
[[email protected] ~]# cd /mnt
[[email protected] mnt]# ls
[[email protected]lhost mnt]# cd nfs1
[[email protected] nfs1]# ls
123
[[email protected] 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
[[email protected] nfs3]# cd /mnt/nfs2
[[email protected] 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
[[email protected] nfs2]# ls
[[email protected] 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服务 ####
####################
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 ##默认发布目录
/etc/vsftpd ##配置目录
4.vsftpd服务的配置参数
1)匿名用户设定
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
#<匿名用户上传文件默认权限修改>
anon_umask=xxx
#<匿名用户建立目录>
anon_mkdir_write_enable=YES|NO
#<匿名用户下载>
anon_world_readable_only=YES|NO ##设定参数值为no表示匿名用户可以下载
#<匿名用户删除>
anon_other_write_enable=YES|NO
####################
服务端:
[[email protected] ~]# yum install vsftpd -y
......
[[email protected] ~]# systemctl start vsftpd
[[email protected] ~]# systemctl enable vsftpd
[[email protected] ~]# firewall-cmd --list-all
public (default, active)
interfaces: eth0
sources:
services: dhcpv6-client ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
[[email protected] ~]# firewall-cmd --permanent --add-service=ftp
success
[[email protected] ~]# firewall-cmd --reload
success
[[email protected] ~]# firewall-cmd --list-all
public (default, active)
interfaces: eth0
sources:
services: dhcpv6-client ftp ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
客户端:
[[email protected] ~]# yum install lftp -y
......
[[email protected] ~]# 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
服务端:
[[email protected] ~]# cd /var/ftp/pub
[[email protected] pub]# ls
[[email protected] 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
服务端:
[[email protected] pub]# rpm -qc vsftpd
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
[[email protected] pub]# vim /etc/vsftpd/vsftpd.conf
--------------------------------------------------
12 anonymous_enable=NO
:wq
--------------------------------------------------
[[email protected] pub]# systemctl restart vsftpd
客户端:
[[email protected] ~]# lftp 172.25.50.200
lftp 172.25.50.200:~> ls
Interrupt
lftp 172.25.50.200:~> exit
[[email protected] ~]#
服务端:
[[email protected] pub]# vim /etc/vsftpd/vsftpd.conf
--------------------------------------------------
12 anonymous_enable=YES
29 anon_upload_enable=YES
:wq
--------------------------------------------------
[[email protected] pub]# systemctl restart vsftpd
客户端:
[[email protected] ~]# 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)
服务端:
[[email protected] pub]# ll /var/ftp
total 0
drwxr-xr-x. 2 root root 42 Nov 16 04:24 pub
[[email protected] pub]# chmod 777 /var/ftp/pub
[[email protected] 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)
服务端:
[[email protected] pub]# setenforce 0 ##selinux警告模式;"setenforce 1"selinux禁止模式
[[email protected] 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
服务端:
[[email protected] pub]# chgrp ftp /var/ftp/pub/
[[email protected] pub]# chmod 775 /var/ftp/pub/
[[email protected] 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)
服务端:
[[email protected] 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
--------------------------------------------------
[[email protected] pub]# vim /etc/vsftpd/vsftpd.conf
--------------------------------------------------
30 anon_world_readable_only=NO
:wq
--------------------------------------------------
[[email protected] 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)
服务端:
[[email protected] 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
--------------------------------------------------
[[email protected] pub]# vim /etc/vsftpd/vsftpd.conf
--------------------------------------------------
34 anon_mkdir_write_enable=YES
:wq
--------------------------------------------------
[[email protected] 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
-rw------- 1 14 50 2005 Nov 17 01:08 passwd
drwx------ 2 14 50 6 Nov 17 01:29 westos
lftp 172.25.50.200:/pub> rm passwd
rm: Access failed: 550 Permission denied. (passwd)
服务端:
[[email protected] pub]# man 5 vsftpd.conf
--------------------------------------------------
anon_other_write_enable
If set to YES, anonymous users will be permitted to perform
write operations other than upload and create directory, such as
deletion and renaming. This is generally not recommended but
included for completeness.
Default: NO
--------------------------------------------------
[[email protected] pub]# vim /etc/vsftpd/vsftpd.conf
--------------------------------------------------
35 anon_other_write_enable=YES
:wq
--------------------------------------------------
[[email protected] pub]# systemctl restart vsftpd
客户端:
lftp 172.25.50.200:/pub> rm passwd
rm ok, `passwd‘ removed
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
drwx------ 2 14 50 6 Nov 17 01:29 westos
lftp 172.25.50.200:/pub> rm westos
rm: Access failed: 550 Delete operation failed. (westos)
lftp 172.25.50.200:/pub> rm -r westos
rm ok, `westos‘ removed
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
服务端:
[[email protected] pub]# man 5 vsftpd.conf
--------------------------------------------------
anon_root
This option represents a directory which vsftpd will try to
change into after an anonymous login. Failure is silently
ignored.
Default: (none)
--------------------------------------------------
[[email protected] pub]# vim /etc/vsftpd/vsftpd.conf
--------------------------------------------------
36 anon_root=/home
:wq
--------------------------------------------------
[[email protected] pub]# systemctl restart vsftpd
[[email protected] pub]# ls /home
student
客户端:
lftp 172.25.50.200:/pub> exit
[[email protected] ~]# lftp 172.25.50.200
lftp 172.25.50.200:~> ls
drwx------ 4 1000 1000 84 Jul 10 2014 student
lftp 172.25.50.200:/> mkdir westos
mkdir: Access failed: 550 Create directory operation failed. (westos)
服务端:
[[email protected] pub]# man 5 vsftpd.conf
--------------------------------------------------
anon_umask
The value that the umask for file creation is set to for anony‐
mous users. NOTE! If you want to specify octal values, remember
the "0" prefix otherwise the value will be treated as a base 10
integer!
Default: 077
--------------------------------------------------
[[email protected] pub]# vim /etc/vsftpd/vsftpd.conf
--------------------------------------------------
36 anon_umask=022
37 #anon_root=/home
:wq
--------------------------------------------------
[[email protected] pub]# systemctl restart vsftpd
客户端:
lftp 172.25.50.200:/> exit
[[email protected] ~]# lftp 172.25.50.200
lftp 172.25.50.200:~> cd pub/
cd ok, cwd=/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
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-r--r-- 1 14 50 2005 Nov 17 01:48 passwd
####################
本文出自 “施超Linux学习笔记” 博客,谢绝转载!
以上是关于Linux课程第十五天学习笔记的主要内容,如果未能解决你的问题,请参考以下文章