centos6.2架设samba服务器

文件服务器有很多:nfs,ftp,sftp,samba等,要采用那种服务器要看各自的需求而定。samba服务器的特点是提供了windows的网络邻居访问功能,适用于一般的局域网文件共享,还具有共享打印机的功能。

 

对于centos要先下载几个软件:

samba:提供与samba服务器相关的smbd,nmbd服务程序和logrotate等文件

samba-clietn:提供linux可以作为samba client端的相关工具命令

samba-common:提供samba服务器和客户端的数据配置文件和命令

这些软件都可用yum下载即可

 

在架设samba之前,首先要明白几个专有名词:

hostname:计算名,可以在/etc/sysconfig/network修改

workgroup:工作组名,要共享计算机必须要在同一工作组内

netbios name:等同于windows的计算机名,我叫它作组内域名,默认为hostname,但可以修改

 

现在可以修改samba配置文件,主要是smb.cof文件,它是由samba-common软件提供的,主要分为两部分:

[global] #全局参数配置

workgroup = *** #组名

netbios name = *** #组内域名,可以不用,默认为hostname

server string = ******* #对这个samba服务器的介绍

log file = /var/log/samba/log.%m #日志存储文件,%m代表netbios主机名

max log size = 50 #日志文件最大的kbytes数

security = user    #使用samba服务器本身的用户密码,改选项可以改为share(共享),domain(samba client 密码)

passdb backend = tdbsam #数据库格式

 load printers = no #这个是打印机共享的,我没要

主要的全局参数就这些,可以开启samba服务器了

#各个资源的共享配置

[homes]  #比较特殊的目录,为各个用户的家目录,一般只能自己看见
        comment = Home Directories  #目录说明
        browseable = no              #是否允许所有用户看见该目录
        writable = yes                 #是否可以写入

[mnt]    #这是我共享的目录名
        comment = win7 
        path = /mnt             #目录路径
        browseable = yes  
        writable = yes
        write list = @root     #可以拥有该目录权限的用户组

配置文件已经足够开启samba了,并共享了家目录和/mnt目录,现在要检查一下文件是否有错,可以用testparm命令,如下:

  
  
  
  
  1. root@www sysconfig]# testparm 
  2. Load smb config files from /etc/samba/smb.conf 
  3. rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384) 
  4. Processing section "[homes]" 
  5. Processing section "[printers]" 
  6. Processing section "[mnt]" 
  7. Processing section "[media]" 
  8. Loaded services file OK. 

这样在“[共享目录]”之前没有信息证明没有错误,可以开启服务。

由于我采用的是user方式,所以还要把用户加进samba用户中,可以采用pdbedit命令:

  
  
  
  
  1. [root@www private]# pdbedit -a -u liang 
  2. new password
  3. retype new password

pdbedit还有很多用处,具体用法可以自己查。

在这里提醒一下,用户要登录samba服务器的某个共享文件要满足3个条件:1.samba服务器有该用户;2.该用户已经加入samba用户中;3必须属于这个共享文件write list的用户组。

现在可以开启samba服务:

/etc/init.d/smb start

/etc/init.d/nmb start

这时还不能搞定收工,因为还有selinux要设置,针对samba,selinux有几个选项可以设置的,这要看各人需求而定了,这里直接引用别人的讲解:

//If you want to share files other than home directorie

chcon -t samba_share_t /directory

//If you want to share files with multiple domains

setsebool -P allow_smbd_anon_write=1

//If you are setting up this machine as a Samba server and wish to share the home directories

setsebool -P samba_enable_home_dirs 1

//If you want to use a remote Samba server for the home directories on this machine

setsebool -P use_samba_home_dirs 1

//You can disable SELinux protection for the samba daemon by executing
service smb restart

现在就能收工了。

小贴示:我在windows的网络邻居登录samba时选了记住密码,结果就不能用户切换了,即使重启也不能,后来经csdn论坛热心人指导,可以:

1.windows执行“control userpasswords2”
2.在“详细设置”里面打开“密码管理”
3.删除你那个用户链接
4.重启,重新访问samba


 

 

 

       

你可能感兴趣的:(linux,centos,samba)