如何创建 Windows 10 中可用的 Samba 共享(只读),以便我的朋友将其映射为网络驱动器并能够从中播放电影?

如何创建 Windows 10 中可用的 Samba 共享(只读),以便我的朋友将其映射为网络驱动器并能够从中播放电影?

我在 Linode 上有一个 VPS,上面安装了 Samba。

我想在这个 VPS 上创建一个 Samba 共享,我将在其中放置一些假期视频和一些图片。我希望此文件可供大约 20 人(朋友和家人)只读,无需身份验证。因此他们可以轻松地在本地计算机上播放这些视频并观看这些照片。

我已经根据这个视频创建了一个 Samba 共享: https://youtu.be/7Q0mnAT1MRg

我所做的大部分事情与视频中所示的相同,但我想在我的 Linux 主文件夹中创建一个 Samba 共享:/home/michal/movies/

user:smbuser因此,我没有将andgroup:smbgroup放入 my 中,而是smb.conf使用了当前用于登录 Ubuntu VPS 的用户名,即:michal。我这样做是为了保存对权限、目录所有者和目录组的一些更改。

michal@ubuntu:~$ ls -lah /home/michal/ | grep "^d"
drwxr-xr-x 10 michal michal 4.0K Nov 12 21:35 .
drwxr-xr-x  5 root   root   4.0K Oct  7  2021 ..
drwxrwxr-x 63 michal michal 4.0K Nov  8 22:22 100DaysOfCode
drwx------  2 michal michal 4.0K Oct  3  2021 .cache
drwx------  4 michal michal 4.0K Mar 22  2022 .config
drwxrwxr-x  4 michal michal 4.0K Feb  3  2022 endlessh
drwxrwxr-- 12 michal michal 4.0K Nov 12 00:33 movies
drwxrwxr--  2 michal michal 4.0K May 31 12:55 photos
drwxrwxr-x  2 michal michal 4.0K Jun 26 22:39 .ssh
drwxrwxr-x  5 michal michal 4.0K Nov  8 21:52 .vscode-server

这就是我的smb.conf文件的样子:

[global]
workgroup = WORKGROUP
server string = %h movies server (Samba, Ubuntu)
security = user
name resolve order = bcast host
log file = /var/log/samba/log.%m
max log size = 1000
logging = file
panic action = /usr/share/samba/panic-action %d
server role = standalone server
obey pam restrictions = yes
unix password sync = yes
pam password change = yes
map to guest = bad user
usershare allow guests = yes

[roes_movies]
path = /home/michal/movies/
force user = michal
# force user = smbuser
force group = michal
# force group = smbgroup
# guest ok = yes
create mask = 0774
force create mode = 0774
directory mask = 0775
force directory mode = 0775
public = yes
writable = no

# Note that "guest ok = yes" is a synonym for "public = yes"

说实话,我不明白为什么需要为 Samba 服务创建单独的用户/组。为什么我不能在我的smb.conf文件中分配以前已经存在的“michal”用户和“michal”组。

root@ubuntu:~# root@ubuntu:~# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-network:x:100:102:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
systemd-timesync:x:102:104:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
messagebus:x:103:106::/nonexistent:/usr/sbin/nologin
syslog:x:104:110::/home/syslog:/usr/sbin/nologin
_apt:x:105:65534::/nonexistent:/usr/sbin/nologin
tss:x:106:111:TPM software stack,,,:/var/lib/tpm:/bin/false
uuidd:x:107:112::/run/uuidd:/usr/sbin/nologin
tcpdump:x:108:113::/nonexistent:/usr/sbin/nologin
usbmux:x:109:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin
sshd:x:110:65534::/run/sshd:/usr/sbin/nologin
landscape:x:111:115::/var/lib/landscape:/usr/sbin/nologin
pollinate:x:112:1::/var/cache/pollinate:/bin/false
systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
michal:x:1000:1000:,,,:/home/michal:/bin/bash
leon:x:1001:1001:leon,,,:/home/leon:/bin/bash
mssql:x:998:998::/var/opt/mssql:/bin/bash
asia:x:1002:1002:asia,,,:/home/asia:/bin/bash
fwupd-refresh:x:113:120:fwupd-refresh user,,,:/run/systemd:/usr/sbin/nologin
smbuser:x:997:997::/home/smbuser:/bin/false

这些是我的 Ubuntu 虚拟服务器上的组:

root@ubuntu:~# cat /etc/group
root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:syslog
tty:x:5:syslog
disk:x:6:
lp:x:7:
mail:x:8:
news:x:9:
uucp:x:10:
man:x:12:
proxy:x:13:
kmem:x:15:
dialout:x:20:
fax:x:21:
voice:x:22:
cdrom:x:24:
floppy:x:25:
tape:x:26:
sudo:x:27:michal,leon,asia
audio:x:29:
dip:x:30:
www-data:x:33:
backup:x:34:
operator:x:37:
list:x:38:
irc:x:39:
src:x:40:
gnats:x:41:
shadow:x:42:
utmp:x:43:
video:x:44:
sasl:x:45:
plugdev:x:46:
staff:x:50:
games:x:60:
users:x:100:
nogroup:x:65534:
systemd-journal:x:101:
systemd-network:x:102:
systemd-resolve:x:103:
systemd-timesync:x:104:
crontab:x:105:
messagebus:x:106:
input:x:107:
kvm:x:108:
render:x:109:
syslog:x:110:
tss:x:111:
uuidd:x:112:
tcpdump:x:113:
landscape:x:115:
systemd-coredump:x:999:
michal:x:1000:smbuser
leon:x:1001:
mssql:x:998:
asia:x:1002:
mlocate:x:116:
ssl-cert:x:117:
sgx:x:118:
plocate:x:119:
_ssh:x:114:
fwupd-refresh:x:120:
rdma:x:121:
sambashare:x:122:
smbuser:x:997:

我还运行了testparm检查smb.conf文件中的错误。

root@ubuntu:~# testparm -v
Load smb config files from /etc/samba/smb.conf
Loaded services file OK.
Weak crypto is allowed

Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

相关内容