如何配置samba服务器
系统环境:系统平台:CentOS release 6.3 (Final)Samba版本:samba-3.5.10-125.el6.x86_64Samba Server IP:10.0.0.163防火墙已关闭/iptables: Firewall is not running.SELINUX=disabled安装Samba服务:1、在可以联网的机器上使用yum工具安装,如果未联网,则挂载系统光盘进行安装。1# yum install samba samba-client samba-swat有依赖关系的包samba-common、samba-winbind-clients、libsmbclient将自动安装上去。2、查看安装状况3、安装包说明1234samba-common-3.5.10-125.el6.x86_64 //主要提供samba服务器的设置文件与设置文件语法检验程序testparmsamba-client-3.5.10-125.el6.x86_64 //客户端软件,主要提供linux主机作为客户端时,所需要的工具指令集samba-swat-3.5.10-125.el6.x86_64 //基于https协议的samba服务器web配置界面samba-3.5.10-125.el6.x86_64 //服务器端软件,主要提供samba服务器的守护程序,共享文档,日志的轮替,开机默认选项Samba服务器安装完毕,会生成配置文件目录/etc/samba和其它一些samba可执行命令工具,/etc/samba/smb.conf是samba的核心配置文件,/etc/init.d/smb是samba的启动/关闭文件。4、启动Samba服务器可以通过/etc/init.d/smb start/stop/restart来启动、关闭、重启Samba服务,启动SMB服务5、查看samba的服务启动情况1# service smb status6、设置开机自启动1# chkconfig --level 35 smb on //在3、5级别上自动运行samba服务
如何搭建samba服务器
samba安装和启动
samba的源码安装采用最新版本samba-4.1.14,官网下载。安装过程如下:
$ sudo mkdir /usr/local/samba-4.1.14
$ ./configure --prefix=/usr/local/samba-4.1.14
...
Checking for program xsltproc : not found
Checking for program python : /usr/bin/python
Checking for program python : /usr/bin/python
Checking for program python : /usr/bin/python
Checking for Python version = 2.5.0 : ok 2.7.6
Checking for library python2.7 : not found
Checking for library python2.7 : yes
Checking for program python2.7-config : not found
Checking for program python-config-2.7 : not found
Checking
for custom code
: Could not find the python development headers
/home/anonymalias/Downloads/samba-4.1.14/wscript:100:
error: the configuration failed (see
\'/home/anonymalias/Downloads/samba-4.1.14/bin/config.log\')
上面错误的原因是samba必须依赖python,执行
$ sudo apt-get install python-dev
后面就是make sudo make install,安装ok后,安装目录结构如下:
/usr/local/samba-4.1.14$ ls
bin etc include lib private sbin share va
将源码文件下默认的conf文件拷贝到安装目录下的etc目录中
/usr/local/samba-4.1.14$ cp /home/anonymalias/Downloads/samba-4.1.14/examples/smb.conf.default etc/smb.conf
修改smb.conf中配置
global段添加如下字段
[global]...
netbios name = ubuntu
共享资源字段采用默认配置
[homes]comment = Home Directories
browseable = no
writable = yes
# NOTE: If you have a BSD-style print system there is no need to
# specifically define each individual printer
[printers]comment = All Printers
path = /usr/spool/samba
browseable = no
# Set public = yes to allow user \'guest account\' to print
guest ok = no
writable = no
printable = yes
添加用户名为Ubuntu的账户,
/usr/local/samba-4.1.14$ sudo bin/smbpasswd -a ubuntu
New SMB password:
Retype new SMB password:
samba服务器的用户是依赖于linux的用户,只能添加linux中已存在的用户,否则会出现如下错误:
/usr/local/samba-4.1.14$ sudo bin/smbpasswd -a user1
New SMB password:
Retype new SMB password:
Failed to add entry for user user1.
启动samba 服务
/usr/local/samba-4.1.14$ sudo sbin/nmbd
/usr/local/samba-4.1.14$ sudo sbin/smbd
在Windwos文件管理器或直接win+R,输入server ip,可以看到如下界面:
怎样在Linux系统搭建Samba共享服务器
实验要求:
Samba文件共享服务配置与访问,配置访问用户以及相应权限。
Tips:创建共享目录/test和/share,并且分别在/test下创建文件tf1(只读)tf2(读写) 在/share 下创建文件pf1(只读)和pf2(读写)
1、挂载本地yum源
[root@localhost /]# mkdir /media/cdrom [root@localhost /]# mount /dev/cdrom /media/cdrom/ [root@localhost /]# vim /etc/yum.repos.d/rhel-source.reporhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
base
enabled=1
2、关闭Selinux 和 IPtables
[root@localhost /]# vim /etc/selinux/config //路径 [root@localhost /]# setenforce 0 //临时关闭Selinux [root@localhost /]# /etc/init.d/iptables stop //关闭防火墙3、安装samba服务
[root@localhost /]# yum install samba -y4、创建共享用户
[root@localhost /]# smbpasswd -a smb [root@localhost /]# smbpasswd -a smb5、修改配置文件
[root@localhost /]# vim /etc/samba/smb.confworkgroup = WORKGROUP //Win需要修改为工作组
server string = Samba Server Version %v
security = user //可以改为everyone
passdb backend = tdbsam
[test]path = /test
public = yes
writeable = yes
valid users = smb
[share]path = /share
public = yes
writeable = yes
valid users = smb
6、创建本地共享目录和文件权限
[root@localhost /]# mkdir /test /share [root@localhost /]# chown -R smb.smb /test/ /share/ [root@localhost test]# touch tp1 tp2 [root@localhost test]# chmod 444 tp1 [root@localhost test]# chmod 666 tp2 [root@localhost test]# echo \"111\" /test/tp1 //ceshi 文本 [root@localhost test]# echo \"222\" /test/tp2 [root@localhost test]# service smb restart //开启服务 测试