How to configure Samba Server share on Debian 9 Stretch Linux
- Lubos Rendek
- Debian
- 13 June 2017
Objective
The objective is to perform a basic configuration of Samba server on Debian 9 Stretch Linux to provide access to Samba shares via MS Windows client machine.
Operating System and Software Versions
- Operating System: - Debian 9 Stretch
- Software: - Samba 4.5.8-Debian
Requirements
Privileged access to your Debian system will be required.
Difficulty
EASY
Conventions
- # - requires given linux commands to be executed with root privileges either directly as a root user or by use of
sudo
command - $ - requires given linux commands to be executed as a regular non-privileged user
Scenario
The below configuration procedure will assume a following scenario and pre-configured requirements:
- Server and MS Windows client are located on the same network and no firewall is blocking any communication between the two
- MS Windows client can resolve samba server by hostname
samba-server
- MS Windows client's Workgroup domain is
WORKGROUP
Instructions
Installation
Let's start by Samba server installation:
# apt install samba
Furthermore, for testing purposes it is also recommended to install samba client:
# apt install smbclient
Samba server should now be up and running on your system:
# systemctl status smbd
● smbd.service - Samba SMB Daemon
Loaded: loaded (/lib/systemd/system/smbd.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2017-06-13 10:35:34 AEST; 3min 32s ago
Docs: man:smbd(8)
man:samba(7)
man:smb.conf(5)
Main PID: 1654 (smbd)
Status: "smbd: ready to serve connections..."
CGroup: /system.slice/smbd.service
├─1654 /usr/sbin/smbd
├─1655 /usr/sbin/smbd
├─1656 /usr/sbin/smbd
└─1659 /usr/sbin/smbd
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.
Default Samba Configuration
The main Samba configuration file is called /etc/samba/smb.conf
. Before we start editing smb.conf
config file, let's make a backup of the original configuration file and extract a current configuration relevant lines to a new smb.conf
file:
# cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
# grep -v -E "^#|^;" /etc/samba/smb.conf_backup | grep . > /etc/samba/smb.conf
Your new /etc/samba/smb.conf
should now contain:
# cat /etc/samba/smb.conf
[global]
workgroup = WORKGROUP
dns proxy = no
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
panic action = /usr/share/samba/panic-action %d
server role = standalone server
passdb backend = tdbsam
obey pam restrictions = yes
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
pam password change = yes
map to guest = bad user
usershare allow guests = yes
[homes]
comment = Home Directories
browseable = no
read only = yes
create mask = 0700
directory mask = 0700
valid users = %S
[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
guest ok = no
read only = yes
create mask = 0700
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
browseable = yes
read only = yes
guest ok = no
Restart your samba server and use SMB client to confirm all exported samba groups:
# systemctl restart smbd
# smbclient -L localhost
WARNING: The "syslog" option is deprecated
Enter root's password:
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.5.8-Debian] Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers
IPC$ IPC IPC Service (Samba 4.5.8-Debian)
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.5.8-Debian] Server Comment
--------- -------
LASERPRINTER
LINUXCONFIG Samba 4.5.8-Debian Workgroup Master
--------- -------
WORKGROUP LINUXCONFIG
Add Users
Samba has its own user management system. However, any user existing on the samba user list must also exist within /etc/passwd
file. From this reason, create a new user using useradd
command before creating any new Samba user. Once your new system user eg. linuxconfig
exits, use smbpasswd
command to create a new Samba user:
# smbpasswd -a linuxconfig
New SMB password:
Samba Home Directories Share
By default all home directories are exported read-only and they are not browseable
. To change this default configuration settings change the current homes
share definition to:
[homes]
comment = Home Directories
browseable = yes
read only = no
create mask = 0700
directory mask = 0700
valid users = %S
Every time you make a change to your /etc/samba/smb.conf
configuration file do not forget to restart your samba server daemon:
# systemctl restart smbd
Samba Public Anonymous Share
The following Samba definition will allow any user to read and write data into Samba share under /var/samba/
directory. First, create a new directory and make it accessible by anyone:
# mkdir /var/samba
# chmod 777 /var/samba/
Next, add a new samba share definition within your /etc/samba/smb.conf
Samba configuration file:
[public]
comment = public anonymous access
path = /var/samba/
browsable =yes
create mask = 0660
directory mask = 0771
writable = yes
guest ok = yes
Restart your samba server daemon:
# systemctl restart smbd
Mount Samba Shares
Now, we are ready to turn our attention to MS Windows machine and network map our new Samba share directories. Start by listing all available shares by \\samba-server
command execution:
If all went well you should see the list of all browsable samba shares:
Next, map any of the shared directories by right-clicking on the share and selecting a Map Network Drive...
option. Tick, Connect using different credentials
option and finish the network drive mapping by supplying the user credentials created in previous steps:
Appendix
List Samba users:
# pdbedit -w -L
Delete Samba user:
# pdbedit -x -u username
How to configure Samba Server share on Debian 9 Stretch Linux的更多相关文章
- How To Configure SAMBA Server And Transfer Files Between Linux & Windows
If you are reading this article it means you have a network at home or office with Windows and Linux ...
- How to Install and Configure Bind 9 (DNS Server) on Ubuntu / Debian System
by Pradeep Kumar · Published November 19, 2017 · Updated November 19, 2017 DNS or Domain Name System ...
- Debian 8 升级到 9 Debian 9 How to upgrade Debian 8 Jessie to Debian 9 Stretch
How to upgrade Debian 8 Jessie to Debian 9 Stretch Contents 1. Objective 2. What's New 3. Preparatio ...
- samba server install
要求: create vnc service for win7 access it via vnc viewer. 1TB disk for this Centos PC is used as Sam ...
- Samba: Server setup..
To make samba shard folder permission clear, there are 3 kind of permission need to be paid attentio ...
- The Guideline of Setting Up Samba Server on linux(Ubuntu)
The Guideline of Setting Up Samba Server on linux(Ubuntu) From terminate command window, install the ...
- How to install Samba server on Ubuntu 12.04
Part 1: Configuring anonymous share with samba server To install the samba package,enter the followi ...
- [转]Android与电脑局域网共享之:Samba Server
大家都有这样的经历,通过我的电脑或网上邻居访问另一台计算机上的共享资源,虽然电脑和手机之间可以有多种数据传输方式,但通过Windows SMB方式进行共享估计使用的人并不是太多,下面我就简单介绍一下, ...
- samba server 设置
samba server 设置yum install samba.x86_64systemctl start smb.servicesystemctl enable smb.servicesamb ...
随机推荐
- LeetCode - 刷题经验
1.加快代码速度 刷了前面几道题发现速度总是处于尾部10%,刚开始非常不服,后来仔细一看那些排名靠前的提交,发现了猫腻.几乎每一个提交都有这样的一段代码: static const auto io_s ...
- 搜狗浏览器总是打开123.sogou.com-记搜狗浏览器遭遇劫持一例
昨日,因从网上下载了office2010破解工具,压缩包中有个文件为名为[office 2010激活工具\为保证永久激活,要先点击这个配置,再点击KMSELDIYI激活.exe],单击之后没有反应.后 ...
- 使用RecyclerView实现聊天界面
原文地址:https://blog.csdn.net/wang_wy/article/details/79032698
- docker入门 什么是docker? 为什么使用docker?
1.什么是docker? 轻量级操作系统虚拟化解决方案 2.为什么使用docker? 1.docker的启动是秒级的,比传统虚拟机快很多 2.资源利用率高,一台主机上可同时运行数千个docker容器 ...
- 七、XHTML介绍
XHTML简介 1.什么是XHTML? XHTML指的是可扩展超文本标记语言 XHTML与HTML4.01几乎是相同的 XHTML是更严格更纯净的HTML版本 XHTML得到所有主流浏览器的支持 2. ...
- 事务、事务特性、事务隔离级别、spring事务传播特性
事务.事务特性.事务隔离级别.spring事务传播特性 1.什么是事务: 事务是程序中一系列严密的操作,所有操作执行必须成功完成,否则在每个操作所做的更改将会被撤销,这也是事务的原子性(要么成功, ...
- Hive 任务优化 tips
1. 集群任务队列: 一般有 root.default, root.online, root.offline, root.spark-thiftserver Hue提交的任务一般默认在 defau ...
- Apollo配置中心
背景: 当前我们项目,所有的配置基本都是通过本地properties 文件进行配置的,比如ip地址.端口.消息中间件和数据库连接的各种参数,当我们需要切换环境或调整参数的时候,我们必须手动的修改这些配 ...
- SpringBoot中常用注解@Controller/@RestController/@RequestMapping的区别
@Controller 处理http请求 @Controller //@ResponseBody public class HelloController { @RequestMapping(valu ...
- Kettle安装Kafka Consumer和Kafka Producer插件
1.从github上下载kettle的kafka插件,地址如下 Kafka Consumer地址: https://github.com/RuckusWirelessIL/pentaho-kafka- ...