家庭NAS搭建实战之samba共享

2023-11-16 18:08:41 浏览数 (2)

在这里插入图片描述在这里插入图片描述

一、系统环境

代码语言:shell复制
root@onecloud:~# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@onecloud:~# 

二、配置仓库源

1.备份原有仓库源

代码语言:shell复制
cp  /etc/apt/sources.list  /etc/apt/sources.listbak   #备份原有配置文件

2.配置新debain源

代码语言:shell复制
deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian-security stretch/updates main
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
#deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
#deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib

3.更新debain源

代码语言:shell复制
apt-get update

二、安装samba软件

1.安装软件

代码语言:shell复制
root@onecloud:/var/lib/dpkg# apt-get install -y   samba

2.设置共享目录

代码语言:shell复制
mkdir -p /data/NAS/nas

3.设置共享目录权限

代码语言:shell复制
root@onecloud:~# chmod 777 /data/NAS/nas/
root@onecloud:~# ls -ld /data/NAS/nas/
drwxrwxrwx 3 root root 4096 Jan 24 22:53 /data/NAS/nas/

4.新建samba用户

代码语言:shell复制
root@onecloud:~# groupadd it
root@onecloud:~# useradd -g it admin
root@onecloud:~# sabpasswd -a admin


root@onecloud:~# smbpasswd -a admin
New SMB password:
root@onecloud:~# smbpasswd -a admin
New SMB password:
Retype new SMB password:
Added user admin.

5.查看smba用户列表

代码语言:shell复制
root@onecloud:~# pdbedit -L
admin:1003:
root@onecloud:~# 

三、修改samba配置文件

代码语言:shell复制
root@onecloud:~# vim /etc/samba/smb.conf
[share]
      path = /data/NAS/nas/
      browseable = yes
      write list = @it
      hosts allow = 192.168.3.0/24

四、测试配置文件

代码语言:shell复制
root@onecloud:~# testparm /etc/samba/smb.conf 
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[share]"
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

# Global parameters
[global]
	idmap config * : backend = tdb


[share]
	path = /data/NAS/nas/
	hosts allow = 192.168.3.0/24
	write list = @it
root@onecloud:~# 

五、设置开机自启服务

代码语言:shell复制
root@onecloud:~# systemctl start smbd
root@onecloud:~# systemctl enable smbd
Synchronizing state of smbd.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable smbd
root@onecloud:~# 

六、测试登录

windows电脑登录

在这里插入图片描述在这里插入图片描述
在这里插入图片描述在这里插入图片描述

我正在参与2023腾讯技术创作特训营第三期有奖征文,组队打卡瓜分大奖!

0 人点赞