在OpenSuse 13.2上安装Samba服务器

Samba服务器安装在OpenSuse 13.2上

版本1.0
作者:Srijan Kishore <s [dot] kishore [at] ispconfig [dot] org>
在Twitter上关注youcl

本指南介绍了如何使用匿名和安全的samba服务器在OpenSuse 13.2中配置samba服务器。 Samba是一个开源/免费软件套件,可为SMB / CIFS客户端提供无缝文件和打印服务。 与其他SMB / CIFS实现不同,Samba可以免费使用,并允许Linux / Unix服务器和基于Windows的客户端之间的互操作性。

1初步说明

我有新安装的OpenSuse 13.2服务器,我将在其上安装samba服务器。 当然,您需要有一台Windows机器来检查必须使用OpenSuse 13.2服务器可以访问的samba服务器。 我的OpenSuse 13.2服务器的hostname server1.example.com &IP为192.168.0.100

您可以从教程的起始五章安装OpenSuse 13.2服务器。

注意:

  • Windows机器必须在同一个工作组上。 要检查Windows机器中的值,请在cmd提示符下运行命令
net config workstation

会是这样的



您的Windows机器必须与OpenSuse 13.2服务器中的Workstation域相同,即在我的情况下为 WORKGROUP
  • 要使Windows机器在Windows中可以进行如此进行。 在运行终端并添加您的服务器IP地址的条目
notepad C:\Windows\System32\drivers\etc\hosts

在我的情况下,就是这样,只是保存值。

[...]
192.168.0.100 server1.example.com opensuse


2匿名Samba分享

首先,我将解释安装Samba与匿名分享的方法。 要安装samba run,

zypper install samba samba-client

它会要求你的输入

server1:~ # zypper install samba samba-client
Loading repository data...
Reading installed packages...
Resolving package dependencies...

Problem: patterns-openSUSE-minimal_base-conflicts-13.2-13.6.1.x86_64 conflicts with samba-client provided by samba-client-4.1.6-3.18.1.x86_64
 Solution 1: Following actions will be done:
  do not install samba-client-4.1.6-3.18.1.x86_64
  do not install samba-4.1.6-3.18.1.x86_64
 Solution 2: deinstallation of patterns-openSUSE-minimal_base-conflicts-13.2-13.6.1.x86_64

Choose from above solutions by number or cancel [1/2/c] (c):<--2
Resolving dependencies...
Resolving package dependencies...

The following 41 NEW packages are going to be installed:
  cifs-utils cups-libs libarchive13 libdcerpc0 libdcerpc-binding0 libfam0
  libgensec0 libjbig2 libjpeg8 libldb1 libndr0 libndr-krb5pac0 libndr-nbt0
  libndr-standard0 libnetapi0 libpdb0 libregistry0 libsamba-credentials0
  libsamba-hostconfig0 libsamba-util0 libsamdb0 libsmbclient0 libsmbclient-raw0
  libsmbconf0 libsmbldap0 libtalloc2 libtdb1 libtevent0 libtevent-util0
  libtiff5 libwbclient0 perl-Crypt-SmbHash perl-Digest-MD4 perl-XML-LibXML
  pytalloc samba samba-client samba-libs yast2-kerberos-client
  yast2-samba-client yast2-samba-server

The following package is going to be REMOVED:
  patterns-openSUSE-minimal_base-conflicts

41 new packages to install, 1 to remove.
Overall download size: 11.1 MiB. After the operation, additional 32.4 MiB will
be used.
Continue? [y/n/? shows all options] (y): <--y


它将安装samba 版本4.1.6-3.18.1-3208-SUSE-oS13.2-x86_64

现在在配置samba 之前编辑文件/etc/samba/smb.cnf 进行更改之前,我将把原始文件备份为 /etc/samba/smb.cnf.bak

cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
cat /dev/null  > /etc/samba/smb.conf

进一步给出这样的条目

vi /etc/samba/smb.cnf
[global]
      
workgroup = WORKGROUP
passdb backend = tdbsam
server string = Samba Server %v netbios name = opensuse security = user map to guest = bad user dns proxy = no #============================ Share Definitions ============================== [Anonymous] path = /samba/anonymous browsable =yes writable = yes guest ok = yes read only = no
mkdir -p /samba/anonymous

接下来在启动时添加服务,并启动服务:

systemctl start smb.service 
systemctl start smb.service

注意:我们需要允许服务超出防火墙,因此我们将在yast2中添加服务:

yast2



允许服务在防火墙中覆盖Samba Client和Samba Server。

现在您可以访问Windows中的OpenSuse 13.2共享,如下所示:


从Windows机器只是浏览文件夹并尝试创建一个文本文件,但你会得到一个权限被拒绝的错误。

检查共享文件夹的权限。

ls -l /samba/
server1:~ # ls -l /samba/
total 0
drwxr-xr-x 1 root root 0 Nov 11 09:41 anonymous
server1:~ #

允许匿名用户授予权限如下:

cd / samba 
chmod -R 0777匿名/
ls -l
server1:/samba # ls -l
total 0
drwxrwxrwx 1 root root 0 Nov 11 09:41 anonymous
server1:/samba #

现在匿名用户可以浏览并创建文件夹内容。


您也可以在服务器上检查内容。

ls -l anonymous/
server1:/samba # ls -l anonymous/
total 0
-rwxr--r-- 1 nobody nobody 0 Nov 21 14:10 anonymous_test.txt
server1:/samba #


3.安全的Samba服务器

为此,我将创建一个组smbgrp和用户srijan以正确的身份验证访问samba服务器

groupadd smbgrp
useradd srijan -G smbgrp
smbpasswd -a srijan
server1:~ # smbpasswd -a srijan
New SMB password:
Retype new SMB password:
Added user srijan.
server1:~ #
server1:/samba # smbpasswd -a srijan
New SMB password: <--srijanpasswd
Retype new SMB password: <--srijanpasswd
Added user srijan.
server1:/samba #

现在创建文件夹viz 保护/ samba文件夹中,并给出这样的权限

mkdir -p /samba/secured
cd /samba
chmod -R 0770 secured/

再次将配置文件编辑为:

vi /etc/samba/smb.conf
[...]
[secured] path = /samba/secured valid users = @smbgrp guest ok = no writable = yes browsable = yes
systemctl restart smb.service


进一步交叉检查设置检查如下:

testparm
server1:~ # testparm 
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[Anonymous]"
Processing section "[secured]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
    netbios name = OPENSUSE
    server string = Samba Server %v
    map to guest = Bad User
    dns proxy = No
    idmap config * : backend = tdb

[Anonymous]
    path = /samba/anonymous
    read only = No
    guest ok = Yes

[secured]
    path = /samba/secured
    valid users = @smbgrp
    read only = No
server1:~ #

现在在Windows机器上检查文件夹现在具有正确的凭据




你会再次面临权限的问题给用户srijan的写权限:


cd /samba
chown -R srijan:smbgrp secured/

现在samba用户 srijan有权写入文件夹。干杯你在OpenSuse 13.2中做了samba服务器



我们可以在Ubuntu服务器上检查文件:
ls -l /samba/secured/
server1:~ # ls -l /samba/secured/
total 0
-rwxr--r-- 1 srijan users 0 Nov 21 14:16 secured_test.txt
server1:~ #

欢呼现在我们通过OpenSuse 13.2成功配置了samba服务器:)

4链接

赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏