【ubuntu 】使用samba配置共享用户home目录和其他具体路径

目录

[1 安装samba](#1 安装samba)

[2 修改Samba配置文件](#2 修改Samba配置文件)

[3 增加Rose用户的samba帐号](#3 增加Rose用户的samba帐号)

[4 重启samba](#4 重启samba)

[5 测试](#5 测试)


1 安装samba

使用如下命令安装samba

复制代码
sudo apt-get update

sudo apt-get install samba openssh-server

2 修改Samba配置文件

复制代码
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.ba

# 打开文件

sudo vim /etc/samba/smb.conf
  • 修改 ①

文件中的**[homes]项** 内容默认是注释掉的,我们取消注释,修改成如下:

复制代码
#======================= Share Definitions =======================


# Un-comment the following (and tweak the other settings below to suit)

# to enable the default home directory shares. This will share each

# user's home directory as \\server\username

[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.

# Un-comment the following parameter to make sure that only "username"

# can connect to \\server\username

# This might need tweaking when using external authentication schemes

   valid users = %S
  • 修改 ②

说明:用于指定共享的具体路径。

在文件的末尾,追加如下内容:

复制代码
[test]

   comment = Shared smb_base

   path = /home/test/

   create mask = 0755

   directory mask = 0755

   writable = yes

   valid users = Rose

   browseable = yes

如上修改完成后**++++wq++++**保存退出!

3 增加Rose用户的samba帐号

Rose为用户名,给Rose开通samba帐号的命令如下:

bash 复制代码
sudo smbpasswd -a Rose

然后根据提示设置对应的密码即可。

4 重启samba

bash 复制代码
sudo service smbd restart && service nmbd restart

5 测试

Windows下输入samba地址尝试登录:

示例如下:

bash 复制代码
\\你要连接的电脑的IP地址\test

然后,输入用户名Rose和对应的密码就可以访问共享的文件夹了。。。

至此,本文分享的内容就结束啦!遇见便是缘,感恩遇见 !!!💛 💙 💜 ❤️ 💚 💛 💙 💜 ❤️ 💚

相关推荐
super_lzb12 小时前
【技术实战系列】windows系统如何模拟tail命令效果
windows·tail命令·日志查看·windows tail·windowstail命令
fengsen521131412 小时前
Windows操作系统部署Tomcat详细讲解
java·windows·tomcat
Full Stack Developme12 小时前
spring #{} 与 ${} 区别
windows·python·spring
魑-魅-魍-魉13 小时前
金仓数据库(KingbaseES)V8R3 Windows 版大小写敏感设置详解
数据库·windows·金仓
charlie11451419114 小时前
RK3568跑Ubuntu 24.04全路程指南(以正点原子的RK3568开发板为例子)
linux·笔记·ubuntu·rootfs·教程·环境配置·rk3568
瀚高PG实验室14 小时前
hghac8008漏洞扫描处理
linux·网络·windows·瀚高数据库
xiaoliuliu1234515 小时前
phpwind_UTF8_8.5部署步骤详解(含环境准备+安装教程)
windows
IT古董15 小时前
Next.js 本地 HTTPS + 自定义域名无法访问问题排查(Windows / mkcert / HSTS 完整指南)
windows·https·next.js
至此流年莫相忘16 小时前
Linux部署k8s(Ubuntu)
linux·ubuntu·kubernetes
henry10101016 小时前
Debian/Ubuntu EC2实例上一键部署WireGuard
ubuntu·云计算·debian·aws