0

My issue is similar to the stackoverflow question, virtual centOS 6.2 - How to share /var/www using Samba, however I am getting the following error:

Windows cannot access \server1\dev You do not have permission to access \\server1\dev

I installed ubuntu server and I am trying to give the /var/www/html/dev directory read and write permissions from other computers (ex: windows 7 and ubuntu desktop).

I changed the owner of folder /var/www to the www-data group and added user dev1 to that group. I then gave 0755 permission to the folder /var/www And below are the contents of my smb.conf file:

[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = ubuntu
security = user
map to guest = bad user
dns proxy = no

#============================ Share Definitions ============================== 
[sharing]
path = /samba/share
browsable =yes
writable = yes
guest ok = yes
read only = no
force user = nobody

[dev]
path = /var/www/html/dev
valid users = @www-data
read only = no
guest ok = no
writable = yes
browsable = yes

So I am tried to access the dev share using a password. I have also added a samba user by following this tutorial, but when I attempt to access this share from windows 7 machine, I receive the following error message:

Windows cannot access \server1\dev.  You do not have permission to access \\server1\dev  

Additional information

I can access /samba/share but cannot access the dev share.

EDIT: Now the windwos system asking to enter password. But after entering password I get the error \\s1\dev is not accessible. You might not have permission to use this network resource. Contact the administrator of this server to find out if you have access permissions.

  • Do you have selinux enabled? If so you may have to change the type of the files and directories shared by httpd and smbd from httpd_sys_content_t to public_content_t (read-only) or public_content_rw_t (read-write). – Tomek Jul 23 '18 at 6:39
1

Credit: Martin

You need to change your samba mount configuration so that you give permission to the www-data user and group to write to it. You may or may not have the ability to set specific directory permissions, but if not you'll have to set the entire drive the write access (which is bad for security).

I would personally advise using nfs instead of samba shares for networked storage and the use of ext3 or other fully featured file system.

http://www.cyberciti.biz/tips/how-do-i-set-permissions-to-samba-shares.html

https://help.ubuntu.com/community/Samba/SambaClientGuide

http://www.mattvanstone.com/2006/06/automatically_mounting_smb_sha/

0

www-data is a system account (<1000 uid/gid) and has no password at all. I would not advice to use uid & gid below 1000. Instead create a new account or use an exsisiting one with uid >1000.

Maybe you want to create a new account for editing webpages via samba only. You can do this by creating a jail.

Hint: You dont need step 1 to 4 when using an exsisting user.

  1. create a jail
# mkdir -p /srv/smb/exampleusername
  1. Add an entry to /etc/fstab
/var/www /srv/smb/exampleusername none bind 0 0
  1. bind /var/www to /srv/smb/exampleusername, so you dont need to reboot to take effect of fstab
# mount -o bind /var/www /srv/smb/exampleusername
  1. create a user, then remove his rights and put him in jail.
# adduser exampleuser
# chown root:root /home/exampleuser
# chmod 0755 /home/exampleuser
# usermod -s /usr/sbin/nologin -d /srv/smb/exampleuser exampleuser
  1. Change the rights of www to that new/specific user.
# chown -R exampleuser:exampleuser /var/www
# chmod -R 0755 /var/www
# chown exampleuser:exampleuser /srv/smb/www
# chmod 0755 /srv/smb/exampleuser
  1. Example share for smb.conf
[www]
path = /srv/smb/exampleuser
comment = yada yada yada
browseable = yes
guest ok = no
valid users = exampleuser
writeable = yes
  1. When not using libpam-smbpass then you need to add the user to smb-db too. I would not advice to use libpam-smbpass for security reasons, but this is up to you. Without this libary you need to add a password for that user.
# smbpasswd -a exampleuser
  1. test your configuration

Done !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.