码迷,mamicode.com
首页 > 其他好文 > 详细

samba

时间:2016-08-04 13:19:26      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

 

samba通过SMB协议,可以实现windows Linux之间的文件共享。

注意关闭selinux

安装samba

[root@samba src]# yum install cups-libs samba samba-common -y

编辑smb.conf配置文件:

下面的[globle]区域下的代码是使linux系统用户能够登录samba服务器:

# ----------------------- Standalone Server Options ------------------------
#
# Scurity can be set to user, share(deprecated) or server(deprecated)
#
# Backend to store user information in. New installations should 
# use either tdbsam or ldapsam. smbpasswd is available for backwards 
# compatibility. tdbsam requires no further configuration.

        security = user
        passdb backend = tdbsam


# ----------------------- Domain Members Options ------------------------

开机启动samba服务

sh-4.1# chkconfig|grep smb
smb                0:off    1:off    2:off    3:off    4:off    5:off    6:off
sh-4.1# chkconfig --levels 236 smb on
sh-4.1# /etc/init.d/smb start
Starting SMB services:                                     [  OK  ]
sh-4.1# chkconfig|grep smb
smb                0:off    1:off    2:on    3:on    4:off    5:off    6:on
sh-4.1# netstat -lnutp|grep smb
tcp        0      0 0.0.0.0:445                 0.0.0.0:*                   LISTEN      1655/smbd           
tcp        0      0 0.0.0.0:139                 0.0.0.0:*                   LISTEN      1655/smbd           
tcp        0      0 :::445                      :::*                        LISTEN      1655/smbd           
tcp        0      0 :::139                      :::*                        LISTEN      1655/smbd 

设置共享文件夹:

下面设置共享文件夹对所有用户可进入:

sh-4.1# tree /home/
/home/

0 directories, 0 files
sh-4.1# cd /home/
sh-4.1# ls
sh-4.1# tree /home/
/home/

0 directories, 0 files
sh-4.1# ls
sh-4.1# tree /home/
/home/

0 directories, 0 files
sh-4.1# mkdir -p /home/shares/allusers
sh-4.1# chown -R root:users /home/shares/allusers/
sh-4.1# chmod -R ug+rwx,o+rx-w /home/shares/allusers/
sh-4.1# tree /home/
/home/
└── shares
    └── allusers

2 directories, 0 files
sh-4.1# getfacl /home/
getfacl: Removing leading / from absolute path names
# file: home/
# owner: root
# group: root
user::rwx
group::r-x
other::r-x

sh-4.1# getfacl /home/shares/allusers/
getfacl: Removing leading / from absolute path names
# file: home/shares/allusers/
# owner: root
# group: users
user::rwx
group::rwx
other::r-x

编辑smb.conf配置文件并在文件末尾增加如下代码:

sh-4.1# vim /etc/samba/smb.conf 
sh-4.1# tail -8 /etc/samba/smb.conf 
[allusers]
    comment = All Users
    path = /home/shares/allusers
    valid users = @users
    force group = users
    create mask = 0660
    directory mask = 0771
    writable = yes

增加下面代码到 /etc/samba/smb.conf可以实现所有用户能够通过samba服务器读写他们自己的根目录:(确保你已经注释或删除其它的[homes]区域代码)
修改之前:

[homes]
        comment = Home Directories
        browseable = no
        writable = yes
;       valid users = %S
;       valid users = MYDOMAIN\%S

修改之后:

[homes]
        comment = Home Directories
        browseable = no
        writable = yes
        valid users = %S
;       valid users = MYDOMAIN\%S
        create mask = 0700
        directory mask = 0700

现在重启Samba服务

sh-4.1# /etc/init.d/smb restart
Shutting down SMB services:                                [  OK  ]
Starting SMB services:                                     [  OK  ]

添加Samba用户:

第一步先增加系统用户bass,如果你想使用已存在的系统用户,可以略过此步

sh-4.1# useradd bass -m -G users
sh-4.1# passwd bass
Changing password for user bass.
New password: 123456
BAD PASSWORD: it is too simplistic/systematic
BAD PASSWORD: is too simple
Retype new password: 123456
passwd: all authentication tokens updated successfully.

第二步将bass系统用户添加至samba用户数据库

sh-4.1# /usr/bin/smbpasswd -a bass
New SMB password:654321#可以跟系统密码不同
Retype new SMB password:654321
Added user bass.

\\192.168.1.107(samba服务器的ip)

技术分享

samba

标签:

原文地址:http://www.cnblogs.com/bass6/p/5736209.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!