当前位置: 首页 > 编程日记 > 正文

cifs------网络文件系统(2)

接着上篇博客继续:

Samba 基本配置

[root@server2 ~]# rpm -qc samba-common             //查看smb的配置文件

1、黑、白名单的设定

默认白名单,设置的ip是黑名单用户:hosts deny = ip
默认黑名单,设置的ip是白名单用户:hosts allow = ip

黑名单 :

        假设不允许ip为172.25.1.2的的主机登陆

服务器端 :

[root@server1 ~]# vim /etc/samba/smb.conf           //编辑配置文件

hosts deny = 172.25.1.2

[root@server1 ~]# systemctl restart smb.service         //服务重启

此时,客户端:

[root@server2 ~]# smbclient -L //172.25.1.1/ -U student                 //服务被拒绝

白名单:

假设只允许ip为172.25.1.2的的主机登陆

服务器端:

[root@server1 samba]# vim /etc/samba/smb.conf             //将黑名单注释掉,并添加白名单

[root@server1 ~]# systemctl restart smb.service        //重启服务

此时,客户端:

[root@server2 ~]#  smbclient //172.25.1.1/student -U student               //可以登陆

2、smb 共享目录

非系统目录的共享

服务器端:

[root@server1 ~]# mkdir /westos

[root@server1 ~]# touch /westos/file{1..5}           //目录下创建文件

修改安全上下文,这里出现了点问题;

[root@server1 ~]# semanage fcontext -a -t samba_share_t '/westos(/.*)?'              //提示没有semanage这个命令
-bash: semanage: command not found

[root@server1 ~]# yum install -y semanage

Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
No package semanage available.
Error: Nothing to do

[root@server1 ~]# yum provides semanage

Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
rhel7.5/filelists_db                                              | 3.4 MB  00:00:00     
policycoreutils-python-2.5-22.el7.x86_64 : SELinux policy core python utilities
Repo        : rhel7.5
Matched from:
Filename    : /usr/sbin/semanage

[root@server1 ~]# yum -y install policycoreutils-python

[root@server1 ~]# semanage fcontext -a -t samba_share_t '/westos(/.*)?'               //此时修改安全上下文

[root@server1 ~]# restorecon -FvvR /westos/                     //刷新

[root@server1 ~]# semanage fcontext -l | grep /westos           //过滤查看/westos的安全上下文修改是否成功

[root@server1 ~]# vim /etc/samba/smb.conf

[DIR]                      //可以看到的共享目录的名称
comment = westos file   //对共享目录的描述
path = /westos                //共享目录的绝对路径

[root@server1 ~]# systemctl restart smb.service              //重启服务

客户端:

[root@server2 ~]# smbclient //172.25.1.1/DIR               //匿名登陆
Enter SAMBA\root's password:
Anonymous login successful
tree connect failed: NT_STATUS_ACCESS_DENIED             //登录失败,则匿名用户不可以登陆
[root@server2 ~]# smbclient //172.25.1.1/DIR -U student        //student登陆
Enter SAMBA\student's password:
Try "help" to get a list of possible commands.                  //登陆成功
smb: \> ls
  .                                   D        0  Tue Mar  5 07:17:42 2019
  ..                                 DR        0  Tue Mar  5 07:16:09 2019
  file1                               N        0  Tue Mar  5 07:17:42 2019
  file2                               N        0  Tue Mar  5 07:17:42 2019
  file3                               N        0  Tue Mar  5 07:17:42 2019
  file4                               N        0  Tue Mar  5 07:17:42 2019
  file5                               N        0  Tue Mar  5 07:17:42 2019

17811456 blocks of size 1024. 16542024 blocks available
smb: \> quit                 //退出

系统目录的共享

服务端:

[root@server1 ~]# vim /etc/samba/smb.conf

[root@server1 ~]# systemctl restart smb.service                
[root@server1 ~]# setsebool -P samba_export_all_ro on              //打开该布尔值后可以共享所有目录,比安全上下文的级别高

[root@server1 ~]# ls /mnt
westos

客户端:

[root@server2 ~]# smbclient //172.25.1.1/DIR -U student

smb 权限管理

browseable = no | yes ——更改此参数,不用重启服务
no ——将该共享目录设置为隐藏
yes——将该共享目录设置为显示
writable = yes|no ——更改此参数,需要重启服务

no | yes —— 设置用户是否可写(所有用户)
write list = student ——更改此参数,需要重启服务

允许用户 student 进行写操作(相当于白名单)
write list = @student ——更改此参数,需要重启服务

只允许属于 student 组的用户进行写操作
admin users = 用户名 ——更改此参数,需要重启服务

1.隐藏该共享目录

服务端:

[root@server1 ~]# vim /etc/samba/smb.conf

[root@server1 ~]# systemctl restart smb.service

客户端:

[root@server2 ~]#  smbclient -L //172.25.1.1

2.显示该共享目录,且可写

服务器端:

[root@server1 ~]# vim /etc/samba/smb.conf

[root@server1 ~]# systemctl restart smb.service

[root@server1 ~]# chmod 777 /mnt

客户端:

[root@server2 ~]# mount //172.25.1.1/DIR /mnt -o username=student,password=redhat

[root@server2 ~]# mount //172.25.1.1/DIR /mnt -o username=student,password=redhat
[root@server2 ~]# cd /mnt/
[root@server2 mnt]# ls
westos
[root@server2 mnt]# touch file1
[root@server2 mnt]# ls
file1  westos

[root@server2 mnt]# cd
[root@server2 ~]# umount /mnt/


**************************************

以此类推。。。。。。

smb 多用户挂载

客户端:

[root@server2 ~]# yum install cifs-utils -y

[root@server2 ~]# vim /root/smbpass               //根据挂载规则编写认证所需的文件

[root@server2 ~]# mount -o credentials=/root/smbpass,sec=ntlmssp,multiuser //172.25.1.1/DIR /mnt

//挂载,其中,credentials=/root/smbpass文件指定的用户名、密码,sec=ntlmssp 认证方式认证方式是ntlmssp;查询方式:rpm -ql | grep samba, multiuser为多用户挂载

[root@server2 ~]# df

[root@server2 ~]# cd /mnt/
[root@server2 mnt]# ls
file1  westos
[root@server2 mnt]# useradd file2        //创建用户file2
[root@server2 mnt]# su - file2         //切换到普通用户file2
[file2@server2 ~]$ cd /mnt             
[file2@server2 mnt]$ ls         //无法查看 ,必须指定用户挂载通过smb认证才可以查看

ls: reading directory .: Permission denied
[file2@server2 mnt]$ exit
logout

[root@server2 mnt]# cifscreds --help          //查看相关命令

cifscreds: unrecognized option '--help'
Usage:
    cifscreds add [-u username] [-d] <host|domain>
    cifscreds clear [-u username] [-d] <host|domain>
    cifscreds clearall
    cifscreds update [-u username] [-d] <host|domain>

[root@server2 mnt]# su - file2
Last login: Tue Mar  5 10:02:55 EST 2019 on pts/0
[file2@server2 ~]$ cifscreds add -u student 172.25.1.1                //需要通过smb认证
Password:
[file2@server2 ~]$ cd /mnt/
[file2@server2 mnt]$ ls            //此时可以查看mnt下面的文件

file1  westos

smb 匿名用户访问

服务器端:

[root@server1 ~]# vim /etc/samba/smb.conf

[root@server1 ~]# systemctl restart smb.service


客户端:

[root@server2 mnt]$ smbclient //172.25.1.1/DIR

//即匿名用户此时可以访问到

[root@server2 ~]# mount //172.25.1.1/DIR /mnt -o username=guest,password=""

相关文章:

iOS网络缓存扫盲篇--使用两行代码就能完成80%的缓存需求

原文地址&#xff1a;https://github.com/ChenYilong/ParseSourceCodeStudy/blob/master/02_Parse的网络缓存与离线存储/iOS网络缓存扫盲篇.md 目录 当我们在谈论缓存的时候&#xff0c;我们在谈论什么&#xff1f;GET网络请求缓存 80%的缓存需求&#xff1a;两行代码就可满足…

YARN集群维护部分问题汇总

云梯开发人员在云梯Yarn集群的搭建和维护过程中做了许多工作&#xff0c;本文选择这期间部分较为典型的问题&#xff0c;通过对这些问题的分析和解决方案&#xff0c;为大家分享分布式系统问题调查的经验。 调查的问题 1. 2013年初引入社区0.23时&#xff0c;调查ResourceManag…

linux系统管理及vim

1.管理输入输出 在linux系统中&#xff0c;正确输出的编号为1&#xff0c;错误输出编号为2 在系统中用普通用户执行 "student" find /etc -name passwd 因为student用户权限问题会有以下输出 find: ‘/etc/pki/CA/private’: Permission denied ##没有进入权力…

如何用 OS X 的 Xcode 写C语言程序

這篇是給新手看的。 如果你在 Windows 習慣使用 Visual C 或 Dev-C 的話&#xff0c;到了 Mac OS X 可能會突然不知道要怎麼寫程式&#xff0c;尤其當你已經用 Visual C 的 Debugger 用得很上手的話。 最近我們系上的課充滿了 C programming&#xff0c;我也稍微摸懂了 Xcode 的…

【转】初等数论 ——原根、指标及其应用

转自&#xff1a;http://blog.163.com/gc_chdch126/blog/static/172279052201641935828402/ 学习总结&#xff1a;初等数论&#xff08;3&#xff09;——原根、指标及其应用 2016-05-19 15:58:28| 分类&#xff1a; 信息学——学习总 | 标签&#xff1a;初等数论 数学 |…

互联网产品评论索引

这里收集一些评论文章&#xff0c;定期查看文章观点的正确性&#xff0c;索引持续更新中 网站前期如何获得推广资源 专访陶瑾&#xff1a;微信公众平台开发先行者转载于:https://www.cnblogs.com/needrunning/p/3000353.html

Apache服务器部署(1)

apache&#xff08;web服务器&#xff09;简介&#xff1a; Apache是世界使用排名第一的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上&#xff0c;其跨平台和安全性被广泛使用&#xff0c;是最流行的Web服务器端软件之一。它快速、可靠并且可通过简单的API扩充&…

JavaScript关键字this指向

在js中this始终指向一个调用函数的那个对象 var a有种你干掉我啊; //纯粹调用函数 function test(){ console.log(this.a);//默认指向全局对象 } //test();//>windows.test() //作为对象的方法被调用 Function.prototype.logfunction(){ console.log(this.a); } //此时t为一…

项目开发过程中的收获与思考

2013年7月&#xff0c;我正式毕业了&#xff0c;到公司入职&#xff0c;也就正式成为了一名菜鸟程序员。到今天&#xff0c;2014年1月3日&#xff0c;目前主要的工作是公司一个项目中的一个功能模块&#xff0c;到我进入项目组算起&#xff0c;已经过了四个月了。因此&#xff…

【仿汽车之家】价格区间选择控件

仿照汽车之家iOS客户端“找车”栏目的价格区间选择控件&#xff0c;最终实现效果如下&#xff1a; 一、界面实现 *根据屏幕大小以及刻度的大小&#xff0c;宏定义需要用到的一些值 #define SCREENW [UIScreen mainScreen].bounds.size.width #define SCREENH [UIScreen mainScr…

Apache服务器部署(2)

签名CA证书 环境&#xff1a;server1:172.25.1.1 重置虚拟机 挂载yum源 [rootserver1 ~]# yum install mod_ssl -y //下载ssl模块 [rootserver1 ~]# yum install crypto-utils -y //安装加密软件 [rootserver1 ~]# genkey …

ASCII、Unicode、GBK和UTF-8字符编码的区别联系

一直对编码这块晕晕乎乎&#xff0c;今天终于看到一篇写的很清楚也很风趣的文章&#xff0c;转过来mark一下。 很久很久以前&#xff0c;有一群人&#xff0c;他们决定用8个可以开合的晶体管来组合成不同的状态&#xff0c;以表示世界上的万物。他们看到8个开关状态是好的&…

【iOS】快速集成轮播控件

自己写的一个轮播控件&#xff0c;初始化后只要实现两个数据源方法&#xff0c;几行代码就能快速集成&#xff0c;支持本地图片和网络图片&#xff0c;支持点击事件&#xff0c;可定制播放速度、指示器颜色/位置、默认加载图等&#xff0c;效果&#xff1a; 1.下载地址&#xf…

Hibernate中get方法和load方法的区别

一、get和load方法都是根据id去获得对应数据的&#xff0c;但是获得机制不同&#xff1a;如果使用get方法&#xff0c;hibernate会去确认该id对应的数据是否存在&#xff0c;它首先会去session中去查询(session缓存其实就hibernate的一级缓存)&#xff0c;如果没有&#xff0c;…

DNS高速缓存

DNS相关资料&#xff1a; 1.什么是DNS DNS&#xff08;Domain Name System域名系统&#xff09; 是互联网上存储域名和ip映射关系的一个分布式数据库&#xff0c;它负责把域名转换成ip地址&#xff0c;或ip地址转换为域名。DNS运行于TCP/UDP的53端口上。 2.什么是高速…

将时间改为显示:几天前,几小时前,或者几分钟前

&#xff08;原博客地址&#xff1a;http://blog.csdn.net/kenhins/article/details/38010811&#xff09; 方法一&#xff1a; 个人做法是保存时间戳&#xff0c;然后在前端用jq插件做转换&#xff0c;比如 smart-time-ago ----------------------------------------------- 方…

支持placeholder和自适配高度的TextView控件

一.应用于项目的效果如下&#xff1a; 二.使用方法&#xff1a; 1.导入JXTextView.h头文件 2.初始化,并添加到view中&#xff1a; JXTextView *textView [[JXTextView alloc] initWithFrame:CGRectMake(10, 10, 200, 30)];textView.placeholder "请输入内容";tex…

ZOJ 3735 dp

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode3735 好久没做DP题了&#xff0c;一开始没理解题目里的C(M,3)是干什么&#xff0c;原来就是组合&#xff0c;C M 取3&#xff0c;就等于n*&#xff08;n-1&#xff09;*&#xff08;n-2&#xff09;/6;题目里还有…

haproxy实现高可用及负载均衡

Haproxy简介&#xff1a; Haproxy是一个使用c语言编写的自由开发源代码软件&#xff0c;它提供高可用性、负载均衡、以及基于http和tcp的应用程序代理。Haproxy特别使用于那些负载特别大的web站点。Haproxy运行在当前的硬件上&#xff0c;完全可以支持数以万计的并发连接&#…

Apache转发到Tomcat

#vi /etc/httpd/conf/httpd.conf 添加下面配置 NameVirtualHost *:80 <VirtualHost *:80>ProxyPreserveHost OnServerName www.域名.comProxyPass / http://www.域名.com:8080/system/ErrorLog logs/error_logCustomLog logs/access_log common</VirtualHost> 作者…

.net基础问题

string sqlstr "select BranchCode,BranchName from t_sys_Branch where Jglx_DataDm{0} and IsVisible1"; sqlstr string.Format(sqlstr, departType); 上述代码运行之后 sqlstr"select BranchCode,BranchName from t_sys_Branch where Jglx_DataDmdepartTyp…

【iOS】NSDate分类,获得中国农历

1.说明&#xff1a; 参考网上代码写的一个分类&#xff0c;只需一句代码就可得到NSDate对象所对应的中国农历、星期。 2.使用方法&#xff1a; &#xff08;1&#xff09;导入分类头文件&#xff1a; #import "NSDateChineseDate.h"&#xff08;2&#xff09;NSDat…

LVS_NAT实现负载均衡

简介&#xff1a; 基于NAT机制实现。当用户请求到达director之后&#xff0c;director将请求报文的目标地址(即VIP)改成选定的realserver地址&#xff0c;同时将报文的目标端口也改成选定的realserver的相应端口&#xff0c;最后将报文请求发送到指定的realserver&#xff1b;…

自定义Push和Pop过渡动画

一、效果和源码 本文介绍如何实现一个NavigationController的自定义Push和Pop过渡动画&#xff0c;运行效果如下&#xff1a; 源码&#xff1a;https://github.com/dolacmeng/TransitionDemo 或http://download.csdn.net/detail/dolacmeng/9572384二、准备工作 首先&#xff0…

centos 安装 mysql 5.7

一&#xff0c;wget http://dev.mysql.com/get/mysql57-community-release-el6-8.noarch.rpm 二&#xff0c;yum localinstall mysql57-community-release-el6-8.noarch.rpm 三&#xff0c;yum install mysql-server 四&#xff0c;mysqld --initialize --usermysql 五&#xf…

c语言:婚礼上的谎言

/* 三对新人参加婚礼&#xff0c;三位新郎A,B,C,三位新娘X,Y,Z。 有人想知道谁与谁结婚&#xff0c;于是就问他们&#xff1a; A说他将和X结婚&#xff1b; X说他的未婚夫是C&#xff1b; C说他将和Z结婚。 这人时候知道他们都在说谎。编程求谁与谁结婚&#xff01; */ /* 思路…

redis主从复制、高可用和集群

redis简介&#xff1a; redis是一个key-value存储系统.和Memcached类似&#xff0c;它支持存储的value类型相对更多&#xff0c;包括string(字符串)、list(链表)、set(集合)、zset(sorted set --有序集合)和hashs&#xff08;哈希类型&#xff09;;这些数据类型都支持push/pop、…

对学习编译原理的看法

我认为编译原理这本书是一门与代码做斗争的课程&#xff0c;学习编译原理能够追寻程序设计语言的本质&#xff0c;了解计算机各种语言编译的原理。学习了编译原理能够更加深入的了解计算机各种高级语言使用的原理&#xff0c;能使自己更加容易更加好的学习好程序语言&#xff0…

iOS提示气泡,带动画

1.效果如图&#xff1a; 从项目中抠出来的&#xff0c;做了简单的封装。 2.用法&#xff1a; //顶部提示HYNoticeView *noticeTop [[HYNoticeView alloc] initWithFrame:CGRectMake(50, 66, 250, 40) text:"这里可以查询全城婚礼人的档期哦&#xff01;" position:…

GIt/Github常用命令

1&#xff09;git init:初始化本地仓库 2&#xff09;创建文件&#xff1a;touch read.txt 3&#xff09;当操作本地的文件时&#xff0c;使用常用的命令&#xff0c;如&#xff08;mv&#xff0c;ls。。&#xff09;就可以操作&#xff0c;当操作暂存区的文件时需要在命令前家…