SambaServer基本配置汇总.docx
- 文档编号:363582
- 上传时间:2022-10-09
- 格式:DOCX
- 页数:12
- 大小:159.95KB
SambaServer基本配置汇总.docx
《SambaServer基本配置汇总.docx》由会员分享,可在线阅读,更多相关《SambaServer基本配置汇总.docx(12页珍藏版)》请在冰豆网上搜索。
SambaServer基本配置汇总
RedhatEnterpriseLinux6.2samba服务配置
一,虚拟机打开后,添加rehl-server-6.2镜像文件
第一步,
第二步:
一、安装前准备
1、使用Samba服务器需要防火墙开放以下端口
UDP137UDP138TCP139TCP445
#配置防火墙端口
[root@roothomes~]vi/etc/sysconfig/iptables
-AINPUT-mstate--stateNEW-mtcp-ptcp--dport139-jACCEPT
-AINPUT-mstate--stateNEW-mtcp-ptcp--dport445-jACCEPT
-AINPUT-mstate--stateNEW-mudp-pudp--dport137-jACCEPT
-AINPUT-mstate--stateNEW-mudp-pudp--dport138-jACCEPT
#重启防火墙,使规则生效
[root@roothomes~]/etc/rc.d/init.d/iptablesrestart
2、关闭CentOS6系统的SELinux
[root@roothomes~]vi/etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
#:
wq 保存。
#重启系统
[root@roothomes~]shutdown-rnow 或者init6
二、安装Samba
1、检查Samba服务包是否已安装
[root@roothomes~]rpm-qa|grepsamba
samba-3.5.4-68.el6.x86_64
samba-common-3.5.4-68.el6.x86_64
samba-client-3.5.4-68.el6.x86_64
samba4-libs-4.0.0-23.alpha11.el6.x86_64
samba-winbind-clients-3.5.4-68.el6.x86_64
说明samba已经安装,如果没有安装,运行下面命令安装[root@roothomes~]yuminstallsamba
2、配置samba
[root@roothomes~]chkconfigsmbon #设置Samba开机自动启动
[root@roothomes~]servicesmbstart #启动Samba服务
[root@roothomes~]/etc/init.d/smbrestart #重启
[root@roothomes~]/etc/init.d/smbstop #停止
[root@roothomes~]cp/etc/samba/smb.conf /etc/samba/bak_smb.conf_bak #备份
[root@roothomes~]cp/etc/samba/bak_smb.conf_bak /etc/samba/smb.conf #恢复
[root@roothomes~]vi/etc/samba/smb.conf
[global] #找到这一行(全局设置标签),在此行下面添加如下行:
workgroup=WORKGROUP #工作组名称改为Windows网络所定义的工作组名
serverstring=SambaServer #设置samba服务器的主机名称
security=user #设置samba服务器安全级别为user,即以账号和口令访问
netbiosname=SambaServer #设置Samba服务器访问别名
#在配置文件的末尾添加以下自定义内容
[SambaServer] #在Windows网上邻居中看到的共享目录的名字
comment=SambaServer #在Windows网上邻居中看到的共享目录的备注信息
path=/home/SambaServer #共享目录在系统中的位置
public=no #不公开目录
writable=yes #共享目录可以读写
validusers=SambaServer #只允许SambaServer用户访问
#保存配置
3、添加访问linux共享目录的账号SambaServer
用户家目录为/home/SambaServer,用户登录终端设为/bin/false(即使之不能登录系统)
[root@roothomes~]mkdir-p/home/SambaServer#建立SambaServer文件夹
[root@roothomes~]cd/home/SambaServer
[root@roothomes~]touch samba.txt #创建测试文件samba.txt
[root@roothomes~]useraddSambaServer-d/home/SambaServer-s/bin/false
[root@roothomes~]chownSambaServer:
SambaServer/home/SambaServer-R
4、将用户SambaServer添加入到Samba用户数据库,并设置登录共享目录的密码为:
123456
[root@roothomes~]smbpasswd-aSambaServer
NewSMBpassword:
输入该用户用于登录Samba的密码
RetypenewSMBpassword:
再次确认输入该密码
AddeduserSambaServer.
#备注:
这里设置的密码是SambaServer用户登录该机的Samba共享的密码,非登陆OS的密码;
5、重启Samba服务器
[root@roothomes~]/etc/init.d/smbrestart
6、浏览共享信息
在Windows客户端输入\\ip 或者\\SambaServer #服务器别名
回车之后,会跳出来登录框,输入账号SambaServer,密码123456,即可访问共享目录
问题:
如果无法访问共享目录的内容,请把防火墙停止;
[root@roothomes~]serviceiptablesstop
二
1、安装Samba软件包
#yum-yinstallsambasamba-clientsamba-commonsamba-winbindsamba-winbind-clients
2、启动、查看Samba服务器状态
#servicesmbstart
#servicesmbstatus
3、设置Samba服务器为开机启动
#chkconfigsmbon
#chkconfig--listsmb
smb 0:
off 1:
off 2:
on 3:
on 4:
on 5:
on 6:
off
4、修改Samba服务器住配置文件smb.conf
4.1、备份源文件
#cp-p/etc/samba/smb.conf/etc/samba/smb.conf.orig
4.2、在[global]部分修改字符集设置
[global]
unixcharset=UTF-8
doscharset=GBK
workgroup=SHAREGROUP
4.3、在文件结尾加上客户自定义共享模块
[share]
comment=RHEL6-WindowsShare
path=/home/share
writeable=yes
#是否可写
browseable=yes
#是否可浏览
createmode=0777
#创建文件时的默认属性
directorymode=0777
#创建目录时的默认属性
validusers=share
#指定可访问用户
5、添加共享用户
#groupadd-g1234share-users
#adduser-d/home/share-m-u1234-g1234-c"Sambademouseraccnt"share
#ls-ld/home/share
drwx------.4shareshare-users409611月2816:
56/home/share
6、映射刚添加的用户为同名的samba用户,并设置samba密码(这个密码不同于系统用户密码!
!
)
#smbpasswd-ashare
NewSMBpassword:
RetypenewSMBpassword:
Addeduserdemo.
#
修改Samba用户信息使用pdbedit命令:
pdbedit-ausername#新建Samba用户
pdbedit-xusername#删除Samba用户
pdbedit-L #列出Samba用户列表,读取passdb.tdb数据库文件
pdbedit-Lv #列出Samba用户列表的详细信息
pdbedit-c"[D]"-uusername #暂停该Samba用户的账号
pdbedit-c"[]"-uusername#恢复该Samba用户的账号
修改Samba用户share的密码:
smbpasswdshare #必须先添加Linux用户到Samba用户
7、检测配置参数
#testparm
8、配置SELinuxSecurity参数
8.1、/etc/selinux/config
SELINUX=enforcing
8.2、设置文件夹及其内容的安全属性
#semanagefcontext-a-tsamba_share_t"/home/share(/.*)?
"
#restorecon-R-v/home/share
PS:
如果semanage命令不存在,可以使用这个命令#yum-yinstallpolicycoreutils-python安装
8.3、在防火墙上开启Samba和Sam
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- SambaServer 基本 配置 汇总