linux Samba 搭建

摘要:
Sambaisafreeandopen-sourcesoftwarepackagethatprovidesseamlessfileandprintservicestoSMB/CIFSclients.Sambaisfreelyavailable,unlikeotherSMB/CIFSimplementationsandallowsforinteroperabilitybetweenLinux/Uni

Sambais 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/share1and 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 = \%Lprofiles.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 toStart->Run. Enter the IP address of your Samba server.

Windows 7, 1 nic, bridge, internet [Running] - Oracle VM VirtualBox_004Now you’ll able to access the fully accessed Samba share from your Windows OS clients.

Windows 7, 1 nic, bridge, internet [Running] - Oracle VM VirtualBox_005Create some files and folders in side the share. In my case, I created a folder calledunixmenin my fully accessed anonymous Samba share calledFull Share.

Windows 7, 1 nic, bridge, internet [Running] - Oracle VM VirtualBox_006Create an Authenticated Share

Let us create a Samba user calledskunder Samba group calledsmbgroup:

# useradd sk
# passwd sk

# groupadd smbgroup
# usermod -a -G smbgroup sk

Now assign the userskto Samba user database with following command:

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

Create a new share called/share2and assign this share tosmbgroup, so that the users ofsmbgroupcan access the/share2directory:

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

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

Open up samba configuration file:

# vi /etc/samba/smb.conf

Add the/share2details 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 = \%Lprofiles.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!

Windows 7, 1 nic, bridge, internet [Running] - Oracle VM VirtualBox_007That’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 搭建》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇OC-字符串介绍 C# 中的运算符重载 .下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

nvidia tk1使用记录--基本环境搭建

前言   项目最开始是在X86+Nvidia(ubuntu+opencv+cuda)平台上实现,达到了期望性能,最近考虑将其移植到嵌入式平台,特别是最近nvidia出了tegra X1,基于和我们使用的gtx960相同的架构的gpu且是64位 8核心cpu,于是开始了尝试移植过程。当前TX1才出来,购买不是那么方便,于是拿它的前一代TK1进行一个最基本的评...

CentOS7 docker.repo 用阿里云Docker Yum源

yum安装软件的时候经常出现找不到镜像的情况 https://download.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 12] Timeout on 解决方法:更新/etc/yum.repos.d目录下的docker.repo文件内容,使用阿里的镜像源 [do...

【Hadoop系列】linux SSH原理解析

本文中斜体加粗代表shell指令,操作环境 CentOS6.5 linux root免密码登录链接:【Hadoop系列】linux下 root用户免密码登录远程主机 ssh。 linux 非root用户免密码登录:XXXXXXX(暂未写好) Linux下,使用ssh协议登录远程计算机。让我们先来了解下什么是SSH。 一、什么是SSH?简单说,SSH是一种网...

十三、【ADC】ADC读取S5p6818电源值

一、分析原理图及特性                                                          图1                                                                            图2 S5p6818的ADC0是去读取电源电压,通过ADC0将模...

cent OS 7 安装谷歌浏览器

我直接写一个shell 脚本,  install_google.sh,  bash 命令直接运行就好, 脚本内容如下: (切换root用户执行) set -e  # 出错即退出 echo " [google-chrome]  name=google-chrome  baseurl=http://dl.google.com/linux/chrome/rpm/...

linux系统python3安装pip

环境ubutun14,python版本是python3.6. 今天在安装Pip 时出现ModuleNotFoundError: No module named 'distutils.util'。操作步骤如下: 我们可以通过以下命令来判断是否已安装: pip --version 如果还未安装,则可以使用以下方法来安装: $ curl https://b...