smaba

samba

1samba作用

提供cifs协议实现共享文件

2安装

yum install samba samba-common samba-client -y

systemctl start smb nmb

systemctl enable smb nmb

3添加smb用户

首先系统中要有用户

[[email protected] ~]# id student

uid=1000(student) gid=1000(student) groups=1000(student),10(wheel)

[[email protected] ~]# smbpasswd -a student  创建smb用户

New SMB password:

Retype new SMB password:

Added user student.

[[email protected] ~]# pdbedit -L  查看smb用户信息

student:1000:Student User

[[email protected] ~]# pdbedit -x student  删除smb用户

[[email protected] ~]# pdbedit -L

[[email protected] ~]# setsebool -P samba_enable_home_dirs on  在selinux中可以访问自己的家目录

测试

[[email protected] ~]# smbclient //172.25.254.114/student -U student

Enter student‘s password:

Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]

smb: \> ls

.                                   D        0  Thu Jul 10 19:06:52 2014

..                                  D        0  Thu Jul 10 18:19:09 2014

.bash_logout                        H       18  Wed Jan 29 07:45:18 2014

.bash_profile                       H      193  Wed Jan 29 07:45:18 2014

.bashrc                             H      231  Wed Jan 29 07:45:18 2014

.ssh                               DH        0  Thu Jul 10 18:19:10 2014

.config                            DH        0  Thu Jul 10 19:06:53 2014

40913 blocks of size 262144. 28544 blocks available

4共享目录

[[email protected] ~]# vim /etc/samba/smb.conf

[jj]                     共享名称

comment = local.public   对共享目录的描述

path = /mnt        共享目录的绝对路径

workgroup = WESTOS  共享目录的组

当共享目录为用户自建目录时

[[email protected] mnt]# mkdir /smbshare

[[email protected] mnt]# touch /smbshare/westosxxx

[[email protected] mnt]# vim /etc/samba/smb.conf

[jj]

comment = local.public

path = /smbshare

[[email protected] mnt]# setsebool -P samba_enable_home_dirs 0

[[email protected] mnt]# semanage fcontext -a -t samba_share_t ‘/smbshare(/.*)?‘

/etc/selinux/targeted/contexts/files/file_contexts.local:  line 4 has invalid regex /smbshare(/.*)?:  missing )

PCRE compilation failed for ^/smbshare(/.*)?$ at offset 21: missing )

libsemanage.sefcontext_compile: sefcontext_compile returned error code 255. Compiling /etc/selinux/targeted/contexts/files/file_contexts.local

/etc/selinux/targeted/contexts/files/file_contexts.local:  line 4 has invalid regex /smbshare(/.*)?:  missing )

PCRE compilation failed for ^/smbshare(/.*)?$ at offset 21: missing )

libsemanage.sefcontext_compile: sefcontext_compile returned error code 255. Compiling /etc/selinux/targeted/contexts/files/file_contexts.local

ValueError: Could not commit semanage transaction

[[email protected] mnt]# restorecon -RvvF /smbshare

[[email protected] mnt]# smbclient //172.25.254.114/jj -U student

Enter student‘s password:

Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]

smb: \> ls

.                                   D        0  Sat Jun  3 02:36:48 2017

..                                  D        0  Sat Jun  3 02:36:38 2017

westosxxx                           N        0  Sat Jun  3 02:36:48 2017

40913 blocks of size 262144. 28544 blocks available

smb: \>

semanage fcontext -a -t samba_share_t ‘目录名称(/.*)?‘  配置安全上下文

restorecon -RvvF 目录名称

当共享目录为系统目录时

[[email protected] ~]# touch /mnt/file{1..10}

[[email protected] ~]# cd /mnt

[[email protected] mnt]# ls

file1  file10  file2  file3  file4  file5  file6  file7  file8  file9

[[email protected] mnt]# smbclient //172.25.254.114/jj -U student

Enter student‘s password:

Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]

smb: \> ls

.                                   D        0  Thu Jul 10 19:06:52 2014

..                                  D        0  Thu Jul 10 18:19:09 2014

.bash_logout                        H       18  Wed Jan 29 07:45:18 2014

.bash_profile                       H      193  Wed Jan 29 07:45:18 2014

.bashrc                             H      231  Wed Jan 29 07:45:18 2014

.ssh                               DH        0  Thu Jul 10 18:19:10 2014

.config                            DH        0  Thu Jul 10 19:06:53 2014

40913 blocks of size 262144. 28545 blocks available

smb: \>

[[email protected] mnt]# setsebool -P samba_export_all_ro on  只读共享

[[email protected] mnt]# setsebool -P samba_export_all_rw on  读写共享

[[email protected] ~]# setsebool -P samba_enable_home_dirs on

[[email protected] mnt]# smbclient //172.25.254.114/jj -U student

Enter student‘s password:

Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]

smb: \> ls

.                                   D        0  Sat Jun  3 02:28:28 2017

..                                  D        0  Sat Jun  3 01:30:28 2017

file1                               N        0  Sat Jun  3 02:28:28 2017

file2                               N        0  Sat Jun  3 02:28:28 2017

file3                               N        0  Sat Jun  3 02:28:28 2017

file4                               N        0  Sat Jun  3 02:28:28 2017

file5                               N        0  Sat Jun  3 02:28:28 2017

file6                               N        0  Sat Jun  3 02:28:28 2017

file7                               N        0  Sat Jun  3 02:28:28 2017

file8                               N        0  Sat Jun  3 02:28:28 2017

file9                               N        0  Sat Jun  3 02:28:28 2017

file10                              N        0  Sat Jun  3 02:28:28 2017

40913 blocks of size 262144. 28545 blocks available

smb: \>

匿名用户登陆

[[email protected] mnt]# smbclient //172.25.254.114/jj

Enter root‘s password:

Anonymous login successful

Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]

tree connect failed: NT_STATUS_ACCESS_DENIED

[[email protected] mnt]# vim /etc/samba/smb.conf

123         security = user

124         passdb backend = tdbsam

125         map to guest = bad user

321         [jj]

322         comment = local.public

323         path = /smbshare

324         guest ok = yes

[[email protected] mnt]# systemctl  restart smb.service

[[email protected] mnt]# smbclient //172.25.254.114/jj

Enter root‘s password:

Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]

smb: \> ls

.                                   D        0  Sat Jun  3 02:36:48 2017

..                                  D        0  Sat Jun  3 02:36:38 2017

westosxxx                           N        0  Sat Jun  3 02:36:48 2017

40913 blocks of size 262144. 28545 blocks available

smb: \>

访问控制

hosts allow = 域名  仅允许

host deny = 域名  仅拒绝

[jj]

comment = local.public

path = /smbshare

valid users = westos    当前共享有效用户

valid users = +westos   当前共享有效用户组

valid users = @westos   当前共享有效用户组

[[email protected] mnt]# smbclient //172.25.254.114/jj -U student

Enter student‘s password:

Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]

tree connect failed: NT_STATUS_ACCESS_DENIED

所有用户均可写

服务器

[[email protected] mnt]# vim /etc/samba/smb.conf

[jj]

comment = local.public

path = /mnt

writable = yes                是否可写

[[email protected] mnt]# setsebool -P samba_export_all_rw on

[[email protected] mnt]# chmod o+w /mnt

客机

[[email protected] ~]# mount -o username=student,password=westos //172.25.254.114/jj /mnt/  【smb共享目录】                   【smb用户名以及密码】

[[email protected] ~]# cd /mnt

[[email protected] mnt]# ls

file1  file10  file2  file3  file4  file5  file6  file7  file8  file9  jj

[[email protected] mnt]# touch kill

[[email protected] mnt]# ls

file1  file10  file2  file3  file4  file5  file6  file7  file8  file9  jj  kill

[[email protected] mnt]#

指定用户可写

write list = student        可写用户

write list = +student       可写用户组

write list = @student

admin users = westos      共享超级用户指定

smb多用户挂载

在客机上【不在服务器】

[[email protected] ~]# vim /root/westos

username=student

password=westos

[[email protected] ~]# chmod 600 /root/westos

[[email protected] ~]# yum install cifs-utils -y

[[email protected] ~]# mount -o credentials=/root/westos,multiuser,sec=ntlmssp //172.25.254.114/jj /mnt/

credentials=/root/westos 指定挂载时的认证文件

sec=ntlmssp  smb认证方式

multiuser  支持多用户认证

测试

su - kiosk

ls /mnt

[[email protected] ~]$ ls /mnt

ls: cannot access /mnt: Permission denied    没有认证无法访问

[[email protected] ~]$ cifscreds add -u student 172.25.254.114  认证

Password:

[[email protected] ~]$ ls /mnt

file1  file10  file2  file3  file4  file5  file6  file7  file8  file9  jj  kill

时间: 2024-07-31 06:08:17

smaba的相关文章

Smaba学习

setenforce一定要设置成Disabled,并且重启,中间碰到很多问题都跟这个有关. NFS: 只能工作在LINUX/UNIX中. WINDOWS: CIFS/SMB协议: CIFS:Common Internet File System SMB:Service Message Block NetBIOS:(WINNS) UNC:\\IP\Shared_path UDP:137/UPD(NETBIOS),138/UDP(NETBIOS) TCP:139/TCP(NETBIOS),445/T

CentOS配置smaba与Windows共享文件

操作环境:CentOS 6.5 64bit Linux与Linux间通过什么共享文件呢--NFS,Windows与Windows之间呢--共享文件功能就OK了,那Windows与Linux之间呢? 这就是本段要讲的东东--samba. 检查是否安装samba # rmp -qa|grep samba 若安装了,则会显演示样例如以下, samba4-libs-4.0.0-58.el6.rc4.x86_64 samba-common-3.6.9-168.el6_5.x86_64 samba-winb

smaba服务器的配置

一.samba服务器的安装 1.配置IP地址 vi /etc/sysconfig/network-scripts/ifcfg-eth0文件 2.配置本地YUM源 3.安装samba服务器 [[email protected] /]# yum install -y samba.i686 二.samba服务器的配置 两种访问模式:匿名访问和用户访问 1.匿名访问 1.1 配置 samba 配置文件 修改文件  /etc/samba/smb.conf, 修改 security 参数,部分内容如下 [g

启动smaba后nginx 11 resource temporarily unavailable[转载]

地址:http://thobian.info/?p=1367 题目可能有点标题党,毕竟下面要说到的只是nginx在比较特殊的环境才回出现的500情况. 先说下自己的开发环境: WEB服务器:nginx,搭在本地虚拟机(虚拟机是直接copy过来的) 开发工具:zend studio(这个其实没什么好说的) 虚拟机操作系统:centos 6.0 本地操作系统:win7 本地.虚拟机通过samba实现文件共享.直接在win下修改代码,同步到linux 这几天在修改代码时,发现每次对CSS.JS文件做修

Raspberry开启smaba服务

安装 samba sudo apt-get install samba 修改samba服务配置 sudo vi /etc/samba/smb.conf [disk1] path = /export/home/disk1 valid user = root pi browseable = yes public = yes writable = yes [disk2] path = /export/home/disk2 valid user = root pi browseable = yes pu

Linux Smaba服务器配置

Linux系统默认已经安装了Samba,但是没有安装Samba服务: 1,先查看安装情况:rpm -qa|grep samba 根据系统的安装情况选择下载或者通过光驱安装所缺的rpm包. 我的安装情况是: 使用命令:mount  /dev/cdrom1  /mnt/cdrom1 通过mount把cdrom1挂载到系统临时目录/mnt/cdrom1,在Packets包下面使用命令:rpm -ivh samba.*.rpm包安装. 切换到放置rpm文件的目录 [[email protected]_s

smaba服务

重置虚拟机:IP----172.25.254.137hostname:samba.example.com指定yum source samba服务:windows作为客户端访问linux的共享文件 windows共享出去了文件,即为server端linux如何查看windows的共享文件:安装yum install samba-client -y查看server端共享了什么:smbcliet -L //server端IP -U usersname挂载后使用:mount //server端IP/共享

smaba服务的搭建

一. samba配置1. 什么是sambaSamba服务类似于windows上的共享功能,可以实现在Linux上共享文件,windows上访问,当然在Linux上也可以访问到.是一种在局域网上共享文件和打印机的一种通信协议,它为局域网内的不同计算机之间提供文件及打印机等资源的共享服务. 2. 安装配置sambayum install -y samba samba-client 配置文件解说: [global] 定义全局的配置,workgroup用来定义工作组,相信如果您安装过windows的系统

linux文件共享之nfs和smaba

nfs和samba 1.NFS简介 NFS(Network File System)即网络文件系统,是FreeBSD支持的文件系统中的一种,它允许网络中的计算机之间通过TCP/IP网络共享资源.在NFS的应用中,本地NFS的客户端应用可以透明地读写位于远端NFS服务器上的文件,就像访问本地文件一样. 类unix系统之间实现文件共享功能,不能实现跟windows系统之间实现共享: 2.NFS工作过程: nfs依赖于rpc服务才能工作: nfs工作过程:nfs客户端/nfs服务端 1.nfs服务端,