IGNORANT

ArchLinux配置samba共享文件夹到Windows虚拟机

2019-11-05: 也可以通过smb共享到安卓手机(如xplorer连接smba服务),iPad(如Documents连接smba服务)

安装samba

sudo pacman -S samba

配置

直接sudo vim /etc/samba/smb.conf,新建并改为:

[global]
   workgroup = WORKGROUP
   dns proxy = no
   log file = /var/log/samba/%m.log
   max log size = 1000
   client max protocol = NT1
   server role = standalone server
   passdb backend = tdbsam
   obey pam restrictions = yes
   unix password sync = yes
   passwd program = /usr/bin/passwd %u
   passwd chat = *New*UNIX*password* %n\n *ReType*new*UNIX*password* %n\n *passwd:*all*authentication*tokens*updated*successfully*
   pam password change = yes
   map to guest = Bad Password
   usershare allow guests = yes
   name resolve order = lmhosts bcast host wins
   security = user
   guest account = nobody
   usershare path = /var/lib/samba/usershare
   usershare max shares = 100
   usershare owner only = yes
   force create mode = 0070
   force directory mode = 0070

[Share]
   comment = MShare Directories
   path = <共享路径>本文设为:/home/julian/Documents
   browseable = yes
   read only = no
   create mask = 0700
   directory mask = 0700

设定访问用户

sudo su
mkdir -p /var/lib/samba/usershare    #在 /var/lib/samba 添加 usershares 目录
groupadd sambashare    #建立 sambashare 用户组
chown root:sambashare /var/lib/samba/usershare    #将刚刚建立的文件夹的权限:拥有者更改为 root,群组更改为 sambashare:
chmod 1770 /var/lib/samba/usershare    #让 sambashare 群组中的用户拥有读取,写入和执行此文件夹中内容的权限
usermod -a -G sambashare your_username    #用户添加到群组 sambashare 中,your_username为实际的用户名(本文替换为julian)
smbpasswd -a your_username #添加用户
smbpasswd your_username    #设定用户密码
systemctl stop smb.service #重启 smb.service服务
systemctl start smb.service

虚拟机连接

先查询Linux的ip,ip a

julian  ~  ip a
    ……
    inet 192.168.x.xxx/24 brd 192.168.2.255 scope global dynamic noprefixroute wlp2s0
      ……

记录ip,在Windows下打开计算机,此电脑右键添加映射网络驱动器。
输入ip,点击完成后在输入设定的用户及密码即可。

参考文章:
1.https://wiki.archlinux.org/index.php/Samba_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)
2.https://blog.csdn.net/JNU_kinke/article/details/36624681

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »