How to add permissions to windows user in samba on ubuntu server
To be thorough:
First, create a samba user if you haven't already:
useradd sambauser
smbpasswd -a sambauser
Enter and confirm the password for sambauser
.
Change that part of your /etc/samba/smb.conf
to this:
[share]
comment = Ubuntu File Server Share
path = /srv/samba/share
valid users = sambauser
browsable = yes
writable = yes
write list = sambauser
create mask = 0755
Make sure that the directory and everything that might be inside has the proper ownership and permissions:
chown -R sambauser:sambauser /srv/samba/share
chmod -R 755 /srv/samba/share
Make sure that you have allowed samba
through selinux
with this command if it is enabled. If selinux
is not enabled then you can skip this part:
chcon -R -t samba_share_t /srv/samba/share
Lastly, make sure that the ports are open for samba
on the firewall.
firewall-cmd --permanent --zone=public --add-port=445/tcp
firewall-cmd --permanent --zone=public --add-port=139/tcp
firewall-cmd --reload
systemctl restart firewalld
If using `iptables:
iptables -A INPUT -p tcp --dport 445 -j ACCEPT
iptables -A INPUT -p tcp --dport 139 -j ACCEPT
iptables-save
iptables-restore
Restart the samba service and then log in with the credentials of sambauser
.
Related videos on Youtube
Matthew Tranmer
Updated on September 18, 2022Comments
-
Matthew Tranmer over 1 year
I have this samba network drive configured in ubuntu server for my windows computer and i want to make it so i can read/write but other users can not read or write to the network drive. How can i edit the smb.conf so i can do this? this is my smb.conf at the moment:
[share] comment = Ubuntu File Server Share path = /srv/samba/share browsable = yes guest ok = yes read only = no create mask = 0755
-
Matthew Tranmer over 5 yearsi get a error when i try to access it it says: \\192.168.1.144\fileserver is not accessible
-
Eric Jurgens over 5 yearsmake sure that the share path is owned by the user
-
Matthew Tranmer over 5 yearshow do i do that?
-
Eric Jurgens over 5 yearsuse the chown command to change owner of a file or folder. Look at the chown man page if you have questions about how to use chown.
-
Matthew Tranmer over 5 yearsi get a error when running chcon -R -t samba_share_t /srv/samba/share. the error says: chcon: can't apply partial context to unlabeled file 'Misc'
-
Nasir Riley over 5 years@matthewtranmer Is
selinux
enabled on your system? -
Matthew Tranmer over 5 yearsno it is not, how do i enable it?
-
Nasir Riley over 5 years@matthewtranmer If it's not enabled then you can skip that part. I'll update the answer and you can go ahead and connect if you've done everything else. Be sure that you restart the samba service first.
-
Matthew Tranmer over 5 yearsi still get the error message
-
Nasir Riley over 5 years@matthewtranmer What error?
-
Matthew Tranmer over 5 yearswhen i try to access it on windows i get a error message saying (in brief) \\192.168.1.144\share is not accessible
-
Nasir Riley over 5 years@matthewtranmer Make sure that
samba
is allowed through the firewall via my update. Then make sure that eitherfirewalld
oriptables
are reloaded/restarted and thatsamba
is also restarted. To be sure, runnetstat -tanp | grep smb
and make sure thatsmbd
is listening.