typora/note/工具集/pve/pve开启samba服务.md
2024-12-12 10:48:55 +08:00

83 lines
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### 背景
- 不想安装虚拟机或lxc容器
- 可以方便的在pve宿主机直接查询共享的文件
### 安装samba
- 更换[中科大软件源](http://mirrors.ustc.edu.cn/help/proxmox.html)(可选)
```bash
sed -i 's|^deb http://ftp.debian.org|deb https://mirrors.ustc.edu.cn|g' /etc/apt/sources.list
sed -i 's|^deb http://security.debian.org|deb https://mirrors.ustc.edu.cn/debian-security|g' /etc/apt/sources.list
```
- pve 8 执行
```bash
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/pve bookworm pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list
```
- pve 7 执行
```bash
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/pve bullseye pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list
```
- pve 6 执行
```bash
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/pve buster pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list
```
- 更新软件包缓存安装samba
```bash
apt update
apt install samba samba-common -y
```
### 配置samba用户以及共享目录
- 添加用户
```bash
useradd smbuser
```
- 设置samba用户密码
```bash
smbpasswd -a smbuser
```
- 创建共享目录
```bash
mkdir /mnt/pve/ssd1t/share
```
- 共享目录设置授权
```bash
chown -R smbuser /mnt/pve/ssd1t/share
```
### 配置samba服务
- 修改samba配置文件 `/etc/samba/samba.conf`文件末尾追加配置,其余默认即可
```bash
[share]
comment = smbuser files
path = /mnt/pve/ssd1t/share
guest ok = no
browseable = no
write list = smbuser
```
### 重启samba服务
```bash
systemctl restart smbd
```