samba setting

本文介绍如何通过Samba服务在Linux系统上配置文件共享,包括安装Samba、设置共享文件夹权限、修改smb.conf配置文件及添加网络访问账户等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.
sudo apt-get install samba
sudo apt-get install smbfs
2.
mkdir /home/voider/share/
chmod 777 /home/voider/share/
3.
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
sudo gedit /etc/samba/smb.conf
4.
搜寻这一行文字
# security = user
用下面这几行取代
security = user
username map = /etc/samba/smbusers

将下列几行新增到文件的最后面,假设允许访问的用户为:fans。而文件夹的共享名为 Share
代码:
[Share]
comment = Shared Folder with username and password
path = /home/voider/share
public = yes
writable = yes
valid users = fans
create mask = 0700
directory mask = 0700
force user = nobody
force group = nogroup
available = yes
browseable = yes

然后顺便把这里改一下,找到[global]把 workgroup = MSHOME 改成
代码:
workgroup = WORKGROUP
display charset = UTF-8
unix charset = UTF-8
dos charset = cp936

后面的三行是为了防止出现中文目录乱码的情况。其中根据你的local,UTF-8 有可能需要改成 cp936。自己看着办吧。现在要添加fans这个网络访问帐户。如果系统中当前没有这个帐户,那么
代码:
sudo useradd fans

要注意,上面只是增加了fans这个用户,却没有给用户赋予本机登录密码。所以这个用户将只能从远程访问,不能从本机登录。而且samba的登录密码可以和本机登录密码不一样。现在要新增网络使用者的帐号:
代码:
sudo smbpasswd -a fans
sudo gedit /etc/samba/smbusers

在新建立的文件内加入下面这一行并保存

代码:
fans = “network username”

如果将来需要更改fans的网络访问密码,也用这个命令更改

代码:
sudo smbpasswd -a fans

删除网络使用者的帐号的命令把上面的 -a 改成 -x

代码:
sudo testparm
sudo /etc/init.d/samba restart

windows 下命令行输入 //ip of linux 用户名密码如上面所设置

### Samba Server Administration Guide and Best Practices #### Overview of Samba Configuration Samba configuration primarily revolves around the `smb.conf` file, which controls all aspects of how a Samba server operates. This includes sharing settings, security policies, user management, and more[^1]. The main sections within this file are `[global]`, defining global parameters applicable to all shares; specific share definitions that start with square brackets followed by the name of the share. #### Setting Up Shares To set up shared directories on a Linux system using Samba involves editing the `/etc/samba/smb.conf`. For example, adding a new section like below allows users to access a directory named 'public': ```ini [Public Share] path = /srv/public browsable = yes read only = no guest ok = yes create mask = 0755 directory mask = 0755 ``` This setup creates an open-access folder where anyone can read/write files without needing authentication credentials provided guest access is enabled. #### User Management Managing users requires creating Unix accounts first before setting them as valid Samba users via `smbpasswd -a username`. It's also possible to integrate Active Directory or LDAP services for centralized account control over multiple servers. #### Security Considerations Security measures include restricting network interfaces through which connections may occur (`interfaces = eth0`) and limiting allowed hosts (`hosts allow`). Additionally, enforcing strong passwords and regularly updating software helps protect against vulnerabilities. #### Performance Optimization Tips For better performance, consider tuning buffer sizes (`socket options`), enabling oplocks (opportunistic locking) when clients support it, adjusting log levels appropriately so they do not consume too many resources while still providing useful information during troubleshooting sessions. --related questions-- 1. How does one configure advanced features such as ACLs in Samba? 2. What steps should be taken to migrate from Windows File Services to Samba? 3. Can you explain how to implement roaming profiles using Samba? 4. In what scenarios would integrating Kerberos into my Samba environment benefit me?
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值