【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和对应的密码就可以访问共享的文件夹了。。。

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

相关推荐
2501_9032386531 分钟前
Git Bash:Windows下的强大命令行工具
windows·git·bash·个人开发
若云止水1 小时前
Ubuntu 下 nginx-1.24.0 源码分析 - ngx_init_cycle 函数 - 详解(4)
数据库·nginx·ubuntu
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
吃汤圆的抹香鲸2 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net
学海无涯,行者无疆11 小时前
使用Jenkins实现Windows服务器下C#应用程序发布
windows·c#·jenkins·.net·cicd·自动发布·一键发布
放情12 小时前
Ubutu部署WordPress
ubuntu·云原生
Xiezequan12 小时前
Ubuntu指令(一)
linux·运维·ubuntu
做咩啊~12 小时前
windows设置暂停更新时长
windows
ForTodayzzZ12 小时前
centos和ubuntu安装mysql教程
linux·mysql·ubuntu·centos
尘佑不尘13 小时前
【无标题】oscp备考,oscp系列——Tr0ll1靶场,两种提权方式,ftp匿名登录,ssh爆破,ubuntu内核提权,计划任务
web安全·ubuntu·渗透测试·ssh·vulnhub