Samba is a free and open-source software package that provides seamless file and print services to SMB/CIFS clients. Samba is freely available, unlike other SMB/CIFS implementations and allows for interoperability between Linux/Unix servers and Windows OS-based clients. Using Samba we can easily share files and folders between GNU/Linux and Windows OS systems.

In this tutorial we are going to implement Samba server on OpenSUSE 13.1.

Install Samba

Login as root user:

> su

Install Samba with following command:

# zypper install samba*

Configure Fully Accessed Anonymous Share

Let us create directory /share1 and set full permission. Anybody can access this share:

# mkdir /share1
# chmod -R 777 /share1/

Open up Samba configuration file /etc/samaba/smb.conf file:

# vi /etc/samba/smb.conf

And edit as follows;

Make sure that you have the following line in [global] section. If not found, just add it as shown below:

[...]
passdb backend = tdbsam

[...]

Scroll down further and add this share details at the bottom of the Samba configuration file:

[Full Share]        
        path = /share1
        writable = yes
        browsable = yes
        guest ok = yes
        guest only = yes
        create mode = 0777
        directory mode = 0777

Save and close the file. Enable and start Samba service to save the changes:

# systemctl enable smb.service
# systemctl enable nmb.service # systemctl start smb.service
# systemctl start nmb.service

Test Samba Configuration

Execute the following command to verify the Samba configuration file. It displays the errors if we have any:

# testparm

The above command will display the output as shown below:

Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Can't find include file /etc/samba/dhcp.conf
Processing section "[homes]"
Processing section "[profiles]"
Processing section "[users]"
Processing section "[groups]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[Full Share]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions [global]
    map to guest = Bad User
    printcap name = cups
    logon path = \\%L\profiles\.msprofile
    logon drive = P:
    logon home = \\%L\%U\.9xprofile
    usershare allow guests = Yes
    idmap config * : backend = tdb
    cups options = raw [homes]
    comment = Home Directories
    valid users = %S, %D%w%S
    read only = No
    inherit acls = Yes
    browseable = No [profiles]
    comment = Network Profiles Service
    path = %H
    read only = No
    create mask = 0600
    directory mask = 0700
    store dos attributes = Yes [users]
    comment = All users
    path = /home
    read only = No
    inherit acls = Yes
    veto files = /aquota.user/groups/shares/ [groups]
    comment = All groups
    path = /home/groups
    read only = No
    inherit acls = Yes [printers]
    comment = All Printers
    path = /var/tmp
    create mask = 0600
    printable = Yes
    print ok = Yes
    browseable = No [print$]
    comment = Printer Drivers
    path = /var/lib/samba/drivers
    write list = @ntadmin, root
    force group = ntadmin
    create mask = 0664
    directory mask = 0775 [Full Share]
    path = /share1
    read only = No
    create mask = 0777
    directory mask = 0777
    guest only = Yes
    guest ok = Yes

I don’t want to mess up iptables, so i turned it off:

# rcSuSEfirewall2 stop

Test Anonymous Samba Share on Windows OS Client

Login to Windows OS machine and go to Start -> Run. Enter the IP address of your Samba server.

Now you’ll able to access the fully accessed Samba share from your Windows OS clients.

Create some files and folders in side the share. In my case, I created a folder called unixmen in my fully accessed anonymous Samba share called Full Share.

Create an Authenticated Share

Let us create a Samba user called sk under Samba group called smbgroup:

# useradd sk
# passwd sk # groupadd smbgroup
# usermod -a -G smbgroup sk

Now assign the user sk to Samba user database with following command:

# smbpasswd -a sk
New SMB password:
Retype new SMB password:
Added user sk.

Create a new share called /share2 and assign this share to smbgroup, so that the users of smbgroup can access the /share2 directory:

# mkdir /share2
# chmod -R 755 /share2/
# chown -R sk:smbgroup /share2

Add the above /share2 directory details in Samba configuration file as shown below;

Open up samba configuration file:

# vi /etc/samba/smb.conf

Add the /share2 details at the end:

[secure]
        path = /share2
        writable = yes
        browsable = yes
        guest ok = no
        valid users = @smbgroup

Restart Samba service to save the changes:

# systemctl restart smb.service
# systemctl restart nmb.service

Now test the configuration file with following command:

# testparm

You may see the following like output:

Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Can't find include file /etc/samba/dhcp.conf
Processing section "[homes]"
Processing section "[profiles]"
Processing section "[users]"
Processing section "[groups]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[Full Share]"
Processing section "[secure]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions [global]
    map to guest = Bad User
    printcap name = cups
    logon path = \\%L\profiles\.msprofile
    logon drive = P:
    logon home = \\%L\%U\.9xprofile
    usershare allow guests = Yes
    idmap config * : backend = tdb
    cups options = raw [homes]
    comment = Home Directories
    valid users = %S, %D%w%S
    read only = No
    inherit acls = Yes
    browseable = No [profiles]
    comment = Network Profiles Service
    path = %H
    read only = No
    create mask = 0600
    directory mask = 0700
    store dos attributes = Yes [users]
    comment = All users
    path = /home
    read only = No
    inherit acls = Yes
    veto files = /aquota.user/groups/shares/ [groups]
    comment = All groups
    path = /home/groups
    read only = No
    inherit acls = Yes [printers]
    comment = All Printers
    path = /var/tmp
    create mask = 0600
    printable = Yes
    print ok = Yes
    browseable = No [print$]
    comment = Printer Drivers
    path = /var/lib/samba/drivers
    write list = @ntadmin, root
    force group = ntadmin
    create mask = 0664
    directory mask = 0775 [Full Share]
    path = /share1
    read only = No
    create mask = 0777
    directory mask = 0777
    guest only = Yes
    guest ok = Yes [secure]
    path = /share2
    valid users = @smbgroup
    read only = No

Test Authenticated Share on Windows OS Client

Now go to the Windows OS client and check the authenticated share. It will ask you to enter username and password to access the Samba shares. Enter the username and password that you have created earlier. You’re done!

That’s it. Now you’ll able to access the Samba shares.

转:https://www.unixmen.com/install-and-configure-samba-server-on-opensuse-13-1/

linux Samba 搭建的更多相关文章

  1. 【转帖】Linux上搭建Samba,实现windows与Linux文件数据同步

    Linux上搭建Samba,实现windows与Linux文件数据同步 2018年06月09日 :: m_nanle_xiaobudiu 阅读数 15812更多 分类专栏: Linux Samba 版 ...

  2. Samba搭建Linux和Windows文件共享服务

    一.Samba简介 Samba是在Linux和UNIX系统上实现SMB协议的一个免费软件,由服务器及客户端程序构成.SMB(Server Messages Block,信息服务块)是一种在局域网上共享 ...

  3. Linux服务器搭建相关教程链接整理

    Linux: Linux 教程 | 菜鸟教程 linux下如何添加一个用户并且让用户获得root权限 - !canfly - 博客园 Git: 在 Linux 下搭建 Git 服务器 - 黄棣-dee ...

  4. Linux samba多用户挂载

    samba 多用户挂载 通过multiuser挂载选项,使用基于密码验证和cifscreds实现访问控制在默认情况下,samba共享挂载后,是通过挂载时的验证来实现对挂载资源的访问控制.通过新的mul ...

  5. Linux Samba安装与使用

    一 安装环境: 虚拟机:RedHat  5.4  192.168.75.128 主机环境:WIN7 32bit  192.168.75.1 网络连接方式:NAT 二 安装步骤: 说明: Ø  samb ...

  6. Linux环境搭建-在虚拟机中安装Centos7.0

    最近在空闲时间学习Linux环境中各种服务的安装与配置,都属于入门级别的,这里把所有的学习过程记录下来,和大家一起分享. 我的电脑系统是win7,所以我需要在win7上安装一个虚拟机-VMware,然 ...

  7. windows和linux中搭建python集成开发环境IDE——如何设置多个python环境

    本系列分为两篇: 1.[转]windows和linux中搭建python集成开发环境IDE 2.[转]linux和windows下安装python集成开发环境及其python包 3.windows和l ...

  8. MongoDB学习笔记—Linux下搭建MongoDB环境

    1.MongoDB简单说明 a MongoDB是由C++语言编写的一个基于分布式文件存储的开源数据库系统,它的目的在于为WEB应用提供可扩展的高性能数据存储解决方案. b MongoDB是一个介于关系 ...

  9. Linux下搭建个人网站

    前不久在阿里买了一个服务器,然后开始第一次尝试搭建自己的个人网站.前端采用了bootstrap框架,后端采用的是PHP,数据库使用的是Mysql.新手第一次在linux下搭建遇见很多问题,在这里分享一 ...

随机推荐

  1. JavaScript高级程序设计(读书笔记)之函数表达式

    定义函数的方式有两种:一种是函数声明,另一种就是函数表达式. 函数声明的一个重要特征就是函数声明提升(function declaration hoisting),意思是在执行代码前会先读取函数声明. ...

  2. 从零开始实现简单 RPC 框架 7:网络通信之自定义协议(粘包拆包、编解码)

    当 RPC 框架使用 Netty 通信时,实际上是将数据转化成 ByteBuf 的方式进行传输. 那如何转化呢?可不可以把 请求参数 或者 响应结果 直接无脑序列化成 byte 数组发出去? 答:直接 ...

  3. 【详细、开箱即用】.NET企业微信回调配置(数据回调URL和指令回调URL验证)

    前言: 前段时间因为公司业务需求,需要将微信小程序与企业微信对接通,也就是把小程序绑定到对应的企业微信账号下,在该企业微信的用户可以将该小程序绑定到工作台中,然后可以在工作台中打开该小程序并授权.不过 ...

  4. 10分钟学会Visual Studio将自己创建的类库打包到NuGet进行引用(net,net core,C#)

    前言 NuGet就是一个包(package)管理平台,确切的说是 .net平台的包管理工具,它提供了一系列客户端用于生成,上传和使用包(package),以及一个用于存储所有包的中心库. 对于一个现代 ...

  5. kubernetes使用jenkins Pipeline 部署Nginx

    文章原文 环境需求 kubernetes 未安装参考使用kubeadm安装kubernetes 1.21 jenkins github/gitee/gitlab 静态页面 镜像仓库(我使用的 hub. ...

  6. 窗口函数至排序——SQLServer2012可高用

    常用到的窗口函数 工作中要常对数据进行分析,分析前要对原始数据中找到想要的格式,数据原本存储的格式不一定时我们想要的,要在基础上进行一定的处理,下面介绍的几种方式是常用的数据排序的集中方式,包含 排名 ...

  7. IPsec NAT-T说明和环境搭建

    1. IPsec与NAT的关系 NAT作为一个IPV4的地址转换协议,它最初的目的是用来最解决IPv4地址不足的问题.通过NAT协议,局域网内的多个主机可以共同使用一个公网地址,这在很大程度上减轻了I ...

  8. linux主机安全加固-个人经验

    说明:我并没有一个系统的网络安全知识体系,随笔里面提到的内容是个人在从事运维行业这几年中总结出来的一点经验,仅供大家参考. 说到linux主机安全加固,我可以想到的就是三个方向吧,基线整改.访问控制和 ...

  9. Vue项目中应用TypeScript

    一.前言 与如何在React项目中应用TypeScript类似 在VUE项目中应用typescript,我们需要引入一个库vue-property-decorator, 其是基于vue-class-c ...

  10. docker-compose 的使用和负载均衡的初探

    docker-compose 的使用和负载均衡的初探 前言 a. 本文主要为 Docker的视频教程 笔记. b. 环境为 CentOS 7.0 云服务器 c. 上一篇:Docker 私有仓库 1. ...