前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >在Ubuntu中安装Samba文件服务

在Ubuntu中安装Samba文件服务

原创
作者头像
小陈运维
发布于 2022-11-09 10:50:29
发布于 2022-11-09 10:50:29
1.8K0
举报
文章被收录于专栏:小陈运维小陈运维

在Ubuntu中安装Samba文件服务

安装 samba 服务

代码语言:shell
AI代码解释
复制
root@v:~# apt install samba samba-common
root@v:~# 

创建共享目录

代码语言:shell
AI代码解释
复制
root@v:~# mkdir /cby/smb/ -pv
root@v:~# chmod 777 -R /cby/smb/
root@v:~# 

修改配置文件

代码语言:shell
AI代码解释
复制
# 编写配置文件 实现匿名访问
[share]
path = /cby/smb
public = yes
read only = no
guest ok = Yes
create mask = 0644
force create mode = 0644
directory mask = 0755
force directory mode = 0755
available = yes

# 完整配置如下
root@v:~# vim /etc/samba/smb.conf
root@v:~# cat /etc/samba/smb.conf
#
# Sample configuration file for the Samba suite for Debian GNU/Linux.
#
#
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options most of which 
# are not shown in this example
#
# Some options that are often worth tuning have been included as
# commented-out examples in this file.
#  - When such options are commented with ";", the proposed setting
#    differs from the default Samba behaviour
#  - When commented with "#", the proposed setting is the default
#    behaviour of Samba but the option is considered important
#    enough to be mentioned here
#
# NOTE: Whenever you modify this file you should run the command
# "testparm" to check that you have not made any basic syntactic 
# errors. 

#======================= Global Settings =======================

[global]

## Browsing/Identification ###

# Change this to the workgroup/NT-domain name your Samba server will part of
   workgroup = WORKGROUP

#### Networking ####

# The specific set of interfaces / networks to bind to
# This can be either the interface name or an IP address/netmask;
# interface names are normally preferred
;   interfaces = 127.0.0.0/8 eth0

# Only bind to the named interfaces and/or networks; you must use the
# 'interfaces' option above to use this.
# It is recommended that you enable this feature if your Samba machine is
# not protected by a firewall or is a firewall itself.  However, this
# option cannot handle dynamic or non-broadcast interfaces correctly.
;   bind interfaces only = yes



#### Debugging/Accounting ####

# This tells Samba to use a separate log file for each machine
# that connects
   log file = /var/log/samba/log.%m

# Cap the size of the individual log files (in KiB).
   max log size = 1000

# We want Samba to only log to /var/log/samba/log.{smbd,nmbd}.
# Append syslog@1 if you want important messages to be sent to syslog too.
   logging = file

# Do something sensible when Samba crashes: mail the admin a backtrace
   panic action = /usr/share/samba/panic-action %d


####### Authentication #######

# Server role. Defines in which mode Samba will operate. Possible
# values are "standalone server", "member server", "classic primary
# domain controller", "classic backup domain controller", "active
# directory domain controller". 
#
# Most people will want "standalone server" or "member server".
# Running as "active directory domain controller" will require first
# running "samba-tool domain provision" to wipe databases and create a
# new domain.
   server role = standalone server

   obey pam restrictions = yes

# This boolean parameter controls whether Samba attempts to sync the Unix
# password with the SMB password when the encrypted SMB password in the
# passdb is changed.
   unix password sync = yes

# For Unix password sync to work on a Debian GNU/Linux system, the following
# parameters must be set (thanks to Ian Kahan <<kahan@informatik.tu-muenchen.de> for
# sending the correct chat script for the passwd program in Debian Sarge).
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .

# This boolean controls whether PAM will be used for password changes
# when requested by an SMB client instead of the program listed in
# 'passwd program'. The default is 'no'.
   pam password change = yes

# This option controls how unsuccessful authentication attempts are mapped
# to anonymous connections
   map to guest = bad user

########## Domains ###########

#
# The following settings only takes effect if 'server role = classic
# primary domain controller', 'server role = classic backup domain controller'
# or 'domain logons' is set 
#

# It specifies the location of the user's
# profile directory from the client point of view) The following
# required a [profiles] share to be setup on the samba server (see
# below)
;   logon path = \\%N\profiles\%U
# Another common choice is storing the profile in the user's home directory
# (this is Samba's default)
#   logon path = \\%N\%U\profile

# The following setting only takes effect if 'domain logons' is set
# It specifies the location of a user's home directory (from the client
# point of view)
;   logon drive = H:
#   logon home = \\%N\%U

# The following setting only takes effect if 'domain logons' is set
# It specifies the script to run during logon. The script must be stored
# in the [netlogon] share
# NOTE: Must be store in 'DOS' file format convention
;   logon script = logon.cmd

# This allows Unix users to be created on the domain controller via the SAMR
# RPC pipe.  The example command creates a user account with a disabled Unix
# password; please adapt to your needs
; add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u

# This allows machine accounts to be created on the domain controller via the 
# SAMR RPC pipe.  
# The following assumes a "machines" group exists on the system
; add machine script  = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u

# This allows Unix groups to be created on the domain controller via the SAMR
# RPC pipe.  
; add group script = /usr/sbin/addgroup --force-badname %g

############ Misc ############

# Using the following line enables you to customise your configuration
# on a per machine basis. The %m gets replaced with the netbios name
# of the machine that is connecting
;   include = /home/samba/etc/smb.conf.%m

# Some defaults for winbind (make sure you're not using the ranges
# for something else.)
;   idmap config * :              backend = tdb
;   idmap config * :              range   = 3000-7999
;   idmap config YOURDOMAINHERE : backend = tdb
;   idmap config YOURDOMAINHERE : range   = 100000-999999
;   template shell = /bin/bash

# Setup usershare options to enable non-root users to share folders
# with the net usershare command.

# Maximum number of usershare. 0 means that usershare is disabled.
#   usershare max shares = 100

# Allow users who've been granted usershare privileges to create
# public shares, not just authenticated ones
   usershare allow guests = yes

#======================= Share Definitions =======================

[homes]
   comment = Home Directories
   browseable = no

# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
   read only = yes

# File creation mask is set to 0700 for security reasons. If you want to
# create files with group=rw permissions, set next parameter to 0775.
   create mask = 0700

# Directory creation mask is set to 0700 for security reasons. If you want to
# create dirs. with group=rw permissions, set next parameter to 0775.
   directory mask = 0700

# By default, \\server\username shares can be connected to by anyone
# with access to the samba server.
# The following parameter makes sure that only "username" can connect
# to \\server\username
# This might need tweaking when using external authentication schemes
   valid users = %S

# Un-comment the following and create the netlogon directory for Domain Logons
# (you need to configure Samba to act as a domain controller too.)
;[netlogon]
;   comment = Network Logon Service
;   path = /home/samba/netlogon
;   guest ok = yes
;   read only = yes

# Un-comment the following and create the profiles directory to store
# users profiles (see the "logon path" option above)
# (you need to configure Samba to act as a domain controller too.)
# The path below should be writable by all users so that their
# profile directory may be created the first time they log on
;[profiles]
;   comment = Users profiles
;   path = /home/samba/profiles
;   guest ok = no
;   browseable = no
;   create mask = 0600
;   directory mask = 0700

[printers]
   comment = All Printers
   browseable = no
   path = /var/spool/samba
   printable = yes
   guest ok = no
   read only = yes
   create mask = 0700

# Windows clients look for this share name as a source of downloadable
# printer drivers
[print$]
   comment = Printer Drivers
   path = /var/lib/samba/printers
   browseable = yes
   read only = yes
   guest ok = no
# Uncomment to allow remote administration of Windows print drivers.
# You may need to replace 'lpadmin' with the name of the group your
# admin users are members of.
# Please note that you also need to set appropriate Unix permissions
# to the drivers directory for these users to have write rights in it
;   write list = root, @lpadmin

[share]
path = /cby/smb
public = yes
read only = no
guest ok = Yes
create mask = 0644
force create mode = 0644
directory mask = 0755
force directory mode = 0755
available = yes
root@v:~# 

重启服务

代码语言:shell
AI代码解释
复制
root@v:~# systemctl restart smbd
root@v:~# 

关于

https://www.oiox.cn/

https://www.oiox.cn/index.php/start-page.html

CSDN、GitHub、51CTO、知乎、开源中国、思否、掘金、简书、华为云、阿里云、腾讯云、哔哩哔哩、今日头条、新浪微博、个人博客

全网可搜《小陈运维

文章主要发布于微信公众号

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
搭建Ubuntu12.04交叉编译服务器
最近学着搭建一台Linux服务器作为交叉编译的主机之用,服务器端选择了Ubuntu12.04 LTS桌面版,客户端采用Windows XP平台,使用SSH工具软件putty登录到Linux主机,建立scrathbox2交叉编译环境工具链,模拟arm环境。
ccf19881030
2019/04/24
1.3K0
在Ubuntu中安装Samba文件服务
Samba是一个能让Linux系统应用Microsoft网络通讯协议的软件,而SMB是Server Message Block的缩写,即为服务器消息块 ,SMB主要是作为Microsoft的网络通讯协议,后来Samba将SMB通信协议应用到了Linux系统上,就形成了现在的Samba软件。后来微软又把 SMB 改名为 CIFS(Common Internet File System),即公共 Internet 文件系统,并且加入了许多新的功能,这样一来,使得Samba具有了更强大的功能。
小陈运维
2022/12/20
1.1K0
Samba服务的安装与配置
一、前期准备环境 关闭防火墙: [root@samba ~]# systemctl stop firewalld.service [root@samba ~]# systemctl disable firewalld.service Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
宝耶需努力
2022/12/13
1.2K0
Samba服务的安装与配置
Ubuntu安装Samba
场景: a用户可以共享/data/share/a和/data/share/a/c; b用户可以共享/data/share/b; c用户可以共享/data/share/a/c; 备注: testparm 检查语法 pdbedit smb操作 smbpasswd smb操作 smbpasswd -a xxx 修改xxx用户密码 windows清理链接的smb执行如下cmd && net use * /del 步骤: 1、安装服务 apt-get install samba 2、修改/etc
苦咖啡
2018/04/28
1.6K0
ubuntu 设置samba 精要说明
一: command: mkdir /home/aaron/share chmod 777 /home/aaron/share sudo apt-get install samba sudo apt-get install smbfs sudo useradd dog  sudo smbpasswd -a dog sudo gedit /etc/samba/smb.conf sudo gedit /etc/samba/smbusers sudo /etc/init.d/samba restart
全栈程序员站长
2021/05/06
3960
Samba共享服务_NFS共享存储
红帽官方samba讲解 Samba 是在Linux和UNIX系统上实现SMB协议的一个免费软件,由服务器及客户端程序构成。
全栈程序员站长
2022/11/08
4.2K0
Samba共享服务_NFS共享存储
Samba文件服务器
在早期的网络世界当中,不同主机的文件传输大多使用FTP来进行。不过FTP却有个小小的问题, 那就是你无法直接修改主机上面的文件内容!也就是说,你想要更改Linux主机上面的某个文件时,你必须要将该文件下载后才能修改。在日常办公环境中,操作系统除了windows以外,还有linux或者UNIX。windows和linux或UNIX之间共享文件是无法直接完成的,为了解析不同系统之间的文件和打印机等资源的共享,我们今天来介绍一下samba服务。他可以解决不同系统平台之间的共享问题。
星哥玩云
2022/09/15
11.7K0
Samba文件服务器
samba的使用
下面关于配置文件的详解内容来自:http://yuanbin.blog.51cto.com/363003/115761。
战神伽罗
2019/07/24
2.5K1
samba的配置和使用
SMB是一种Linux、UNIX系统上可用于共享文件和打印机等资源的协议,这种协议是基于Client\Server型的协议,Client端可以通过SMB访问到Server(服务器)上的共享资源。当Windows是 Client,CentOS是服务器时,通过Samba就可以实现window访问Linux的资源,实现两个系统间的数据交互。
summerking
2022/09/19
8520
samba文件共享服务器安装
安装好samba软件包以后,在系统中会添加名为smb和nmb的标准系统服务,管理员可以通过service(centos6)或systemctl(centos7)工具来控制Samba服务的启动与终止。
全栈程序员站长
2022/08/30
2.7K0
samba服务器配置
Samba最大的功能就是可以用于Linux与windows系统直接的文件共享和打印共享,Samba既可以用于windows与Linux之间的文件共享,也可以用于Linux与Linux之间的资源共享,由于NFS(网络文件系统)可以很好的完成Linux与Linux之间的数据共享,因而 Samba较多的用在了Linux与windows之间的数据共享上面。
筱竼
2022/08/18
4.2K0
ubuntu samba share 共享 windows linux
下面我们来共享群组可读写文件夹,假设你要共享的文件夹为: /home/ray/share
全栈程序员站长
2021/05/06
7.5K0
Samba文件共享服务的实现
试验环境:两台主机 服务端:192.168.56.11 客户端:192.168.56.12
星哥玩云
2022/07/14
6020
树莓派SSH开启&&文件共享(samba)
修改其配置文件 /etc/samba/smb.conf, 在文件最后面添加以下内容
云深无际
2021/04/14
1.2K0
树莓派SSH开启&&文件共享(samba)
Samba通过字符界面设置过程
samba通过字符界面设置过程(字符界面添加samba的windows的登陆用户名)
星哥玩云
2022/06/30
8810
玩转企业常见应用与服务系列(五):网络文件共享服务 Samba 原理与实践
Samba 是一个能让 Linux 系统应用 Microsoft 网络通讯协议的软件,而 SMB 是 Server Message Block 的缩写,即为服务器消息块,SMB 主要是作为Microsoft 的网络通讯协议,后来 Samba 将 SMB 通信协议应用到了 Linux 系统上,就形成了现在的 Samba 软件。后来微软又把 SMB 改名为 CIFS(Common Internet File System),即公共 Internet 文件系统,并且加入了许多新的功能,这样一来,使得Samba具有了更强大的功能。
民工哥
2023/11/20
2.5K0
玩转企业常见应用与服务系列(五):网络文件共享服务 Samba 原理与实践
Samba服务的配置总结
之前介绍了Linux下Samba服务器部署,这里简单总结下Samba服务参数的配置说明: Samba服务的主配置文件是smb.conf,默认在/etc/samba/目录下。smb.conf含有多个段,每个段由段名开始,直到下个段名。每个段名放在方括号中间。每段的参数的格式是:名称=指。配置文件中一行一个段名和参数,段名和参数名不分大小写。除了[global]段外,所有的段都可以看作是一个共享资源。段名是该共享资源的名字,段里的参数是该共享资源的属性。Samba安装好后,使用testparm命令可以测试smb
洗尽了浮华
2018/04/08
3.6K0
Samba服务的配置总结
Linux下部署Samba服务环境的操作记录
关于Linux和Windows系统之间的文件传输,很多人选择使用FTP,相对较安全,但是有时还是会出现一些问题,比如上传文件时,文件名莫名出现乱码,文件大小改变等问题。相比较来说,使用Samba作为文件共享,就省事简洁多了。Samba服务器通信协议(Server Messages Block)就是是为了解决局域网内的文件或打印机等资源的共享服务问题,让多个主机之间共享文件变成越来越简单。下面简单介绍下,在Centos7下部署Samba服务的操作记录(测试机192.168.10.204): 1)安装Samba
洗尽了浮华
2018/03/28
2.2K0
Linux下部署Samba服务环境的操作记录
linux文件共享 samba_文件共享服务
Samba 是在 Linux 和 UNIX 系统上实现 SMB 协议的一个免费软件 , 由服务器及客户端程序构成 ; SMB (Server Messages Block , 信息服务块) 是一种在局域网上共享文件和打印机的一种通信协议 , 它为局域网内的不同计算机之间提供文件及打印机等资源的共享服务 ; SMB 协议是 客户机/服务器 型协议 , 客户机通过该协议可以访问服务器上的共享文件系统 , 打印机及其他资源 ; 通过设置 NetBIOS over TCP/IP 使得 Samba 不但能与局域网络主机分享资源 , 还能与全世界的电脑分享资源 ;
全栈程序员站长
2022/11/09
4.1K0
运维Tips | Ubuntu 24.04 安装配置 samba 文件共享
描述:我们将 Ubuntu 24.04 作为机器学习的工作站,往往需要将 Ubuntu 24.04 中的数据或者代码共享给我们其他使用Windows系统的小伙伴,此时我们可以使用SAMBA,开辟出一个文件共享目录供大家进行数据交换使用。
全栈工程师修炼指南
2024/07/16
3.6K0
运维Tips | Ubuntu 24.04 安装配置 samba 文件共享
相关推荐
搭建Ubuntu12.04交叉编译服务器
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档