以下是我正在使用的配置
[global]
workgroup = WORKGROUP
netbios name = CDA
security = user
map to guest = Bad User
username map = /etc/samba/smbusers
guest account = nobody
guest ok = yes
log file = /var/log/samba.log.%m
log level = 2
max log size = 1000
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
printing = bsd
[custom_home]
path = /opt/asdf/custom_home
read only = no
browseable = yes
create mask = 0777
directory mask = 0777
valid users = @writer
我已经创建了一个新的系统用户并将其添加到组 writer。
我还运行了以下命令来获取 samba 密码。
sudo smbpasswd -a testuser
我已授予该文件夹 0777 权限,并且文件夹的所有者是写入者组。我仍然无法写入该文件夹。:(
按照要求:
[global]
workgroup = WORKGROUP
netbios name = CDA
security = user
map to guest = Bad User
username map = /etc/samba/smbusers
guest account = nobody
guest ok = yes
log file = /var/log/samba.log.%m
log level = 2
max log size = 1000
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
printing = bsd
[pi_home]
path = /opt/oracle/psft/pt/pi_home
writable = no
available = yes
[tools_client]
path = /opt/oracle/psft/pt/tools_client
writable = no
available = yes
[ps_app_home]
path = /opt/oracle/psft/pt/ps_app_home
writable = no
available = yes
[ps_home]
path = /opt/oracle/psft/pt/ps_home8.55.11
writable = no
available = yes
[custom_sqr_pshome]
path = /opt/oracle/psft/pt/ps_home8.55.11/sqr_custom
read only = no
available = yes
browseable = yes
writable = yes
guest ok = no
public = yes
locking = no
strict locking = no
create mask = 0777
directory mask = 0777
valid users = sqruser
[custom_sqr_psapphome]
path = /opt/oracle/psft/pt/ps_app_home/sqr_custom
read only = no
available = yes
browseable = yes
writable = yes
guest ok = no
public = yes
locking = no
strict locking = no
create mask = 0777
directory mask = 0777
valid users = sqruser
答案1
执行以下命令删除 samba
sudo apt-get remove --purge samba
sudo apt-get remove --purge smbclient libsmbclient
sudo apt-get purge samba samba-common
sudo rm -rf /etc/samba/ /etc/default/samba
再次安装
sudo apt-get install samba
sudo apt-get install smbclient libsmbclient
现在原始 smb.conf 已恢复,因此重新启动 Ubuntu,然后从终端添加用户。
root@Dell-Inspiron-3521:~# sudo smbpasswd -a username (username should be without space eg "sudo smbpasswd -a alamjitsingh")
New SMB password:*********
Retype new SMB password:*********
Added user alamjitsingh.
现在按如下方式编辑 smb.conf 文件。代码中必须包含上述行。
sudo gedit /usr/share/samba/smb.conf
[global]
workgroup = WORKGROUP
passdb backend = tdbsam
security = user
[可选] 如果您想共享 opt 目录内的文件夹,那么您还必须在全局部分添加以下行。
usershare owner only = False
在身份验证部分,通过在代码开头添加 # 来关闭“映射到客人 = 坏用户”
#map to guest = bad user
最后添加您的个人代码
[sqr_custom]
path = /opt/oracle/psft/pt/ps_home8.55.11/sqr_custom
comment = Personal_Share
read only = no
available = yes
browseable = yes
writable = yes
guest ok = no
public = yes
printable = no
locking = no
strict locking = no
除此之外,您的共享文件夹位于 opt 文件夹中,需要写入权限。因此,首先通过共享主目录的文件夹来测试此程序。然后我们将继续进行。要知道共享文件夹的正确路径,请将文件夹拖放到正在运行的终端上。
如果成功运行上述代码,请执行以下操作
要创建组:
sudo groupadd demoGroup
要将用户帐户添加到组:
sudo usermod -G demoGroup username(eg alamjitsingh)
用于设置写入权限
sudo chown -R username:groupname /opt/demo
例如
sudo chown -R alamjitsingh:demogroup /opt/demo
以下几行用于授予目录 demo 中 demoGroup 成员的写权限(它将授予所有 demoGroup 成员写权限)
sudo chgrp -R demogroup /opt/demo
sudo chmod 2770 /opt/demo
重启服务
sudo service nmbd restart
sudo service smbd restart
例如具有写权限的受限目录的共享文件夹
[demo]
path = /opt/demo
comment = HD Share
read only = no
available = yes
browseable = yes
writable = yes
guest ok = no
public = yes
printable = no
locking = no
strict locking = no
force create mode = 0660
force directory mode = 2770
force user = alamjitsingh
force group = demogroup
答案2
尝试下面提到的代码
[global]
workgroup = WORKGROUP
netbios name = CDA
passdb backend = tdbsam
security = user
#map to guest = Bad User
username map = /etc/samba/smbusers
guest account = nobody
guest ok = yes
log file = /var/log/samba.log.%m
log level = 2
max log size = 1000
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
printing = bsd
[custom_home]
path = /opt/asdf/custom_home
read only = no
available = yes
browseable = yes
writable = yes
guest ok = no
public = yes
locking = no
strict locking = no
create mask = 0777
directory mask = 0777
valid users = @writer (if writer is not username remove this line i think, you added user name = testuser so remove this line)
testuser 很可能是您访问此共享文件夹的用户名。在 Windows 10 中,您必须手动“添加网络位置”,例如“”,\\192.168.1.3\ Shared_folder_name
然后它会要求输入用户名和密码。在 Windows 10 中找到此选项->添加网络位置。在 Android 设备中,您可以通过“ES 文件资源管理器”应用访问此共享目录。如果仍然不起作用,请通知我。祝你好运。