How to allow guest access in SAMBA
In order to set up guest access in Samba, you need to set up a user that it will pretend to log in as. So, let's say you want to share files on /mnt/somepartition/files publically. Your configuration might look like this:
[public_files]
comment = Public files
path = /mnt/somepartition/files
browsable = yes
guest ok = yes
writable = yes
guest account = someusername
create mask = 0775
directory mask = 0755
What this saying is "Create a samba share on \mymachine\public_files that is viewable to anonymous users (not hidden like user files generally are) and enable it for write access. Anonymous users can access this share by using someusername's credentials. When files are created, make them globally executable but restrict write access globally. When directories are created, make them globally executable but only writable by someusername."
Once this is done, you will need to create a smbpassword, per your question. To do this, ensure first that the user exists within your server. If the user doesn't, create it:
sudo adduser someusername
Once the user exists, create a samba login:
sudo smbpasswd -a someusername
A couple of things to keep in mind: the directory that public_files points to will need to be READ accessible to someusername. Make sure you set the permissions correctly. If the directory is owned by you but still want to make them available, add someusername to a common group and then change the group ownership.
Related videos on Youtube
![Blaine](https://i.stack.imgur.com/YTbA6.jpg?s=256&g=1)
Blaine
Random High-school student that enjoys messing around with computers. The main thing I do is run a project (Tech for Teaching) that puts old computer donations into local elementary classrooms in the Philippines. Pretty much all my questions/answers on this site are from experience with fixing donations to this project. If you'd like to know more, techforteachingph.org gives you more information about the project.
Updated on September 18, 2022Comments
-
Blaine almost 2 years
So basically, I'm having the exact same issue as the guy in this thread. I can see the samba print share, but not access it from windows. The top answer, which looks promising states that I must do the following:
You need to add a guest user to the samba password database. Usually it is done by mapping guest in samba configuration files to a UNIX existing user; give that user printing rights via groups; then you should be able to access the printer via the \server\ URI.
Can somebody please explain to me how exactly this is done? I've googled around and it hasn't been of much help.
Thanks!
UPDATE
here is the printer portion of my /etc/samba.conf file. let me know if you want the rest and i'll put it in a google doc or something[printers]
comment = All Printers
; browseable = yes
path = /var/spool/samba
printable = yes
guest ok = yes
; read only = no
guest account = blain
create mask = 0700 -
Blaine about 8 yearswhen executing the 2nd command i get "failed to find entry for user someusername"
-
Blaine about 8 yearsmay have to do with the fact that my config is slightly different to yours possibly because i'm sharing a printer not a directory
-
scuba_mike about 8 yearssorry, try sudo smbpasswd -a someusername
-
scuba_mike about 8 yearsSharing a directory is no different than sharing printers as printers are, very simply put, files.
-
Blaine about 8 yearsthat command works, but the windows client is still unable to connect. I'll update the question with my samba conf file as it looks slightly different
-
scuba_mike about 8 yearsDid you restart samba? After you change the smb.conf, you need to restart the service so that it reads the conf file again.
-
Blaine about 8 yearsYes, i did restart samba
-
scuba_mike about 8 yearsCan you post the contents of your /var/log/samba/* file where * is the appropriate file name for setup?
-
Blaine about 8 yearsthere's 2 log files that might be halpful. log.smbd and log.[name_of_win_client] (interesting that that exists as i never manually put in the name of the windows client computer. Which would you like me to post, and would you like any other ones?
-
Blaine about 8 years
-
scuba_mike about 8 yearsThe log file gets created automatically when your computer attempts to connect to the samba server. So if I had a computer named foobar, you would see log.foobar In any case, can you provide additional information about your setup? How is your printer configured? CUPS or some other method? Also, is the printer directly connected to your computer (e.g. USB) or is it a network printer?
-
Blaine about 8 yearsAlright. The log.foobar file would be the first link in my previous comment. I believe the printer is configured with CUPS, but i'm not entirely sure. I added it using the "add printer" option in Ubuntu (whatever the case i can access it from localhost:631). Printer is connected via USB to server computer, and that is its only interface.
-
scuba_mike about 8 yearsI don't have a USB printer so I'm not sure how to help you much further than giving you [wiki.samba.org/index.php/… documentation). What is the error message you're getting when you connect to the Samba share?
-
lorenzog about 8 yearsThe answer here is correct: you need to issue
sudo smbpasswd -a blaine
asblaine
is the 'guest account' user set in your samba config. The reason is that samba is trying to become the 'blaine' user in order to print, but it can't find that user in its own database. -
Blaine about 8 yearsit asks for a user unix password and an smb password. should these passwords match, does it matter what they are, or should they both match the client computer password
-
Blaine about 8 yearseither way, making both passwords the same as the client computer password throws the same error. Odd thing is that the error pops up almost instantaneously, like it's not even trying (though the log file is still created). See this question superuser.com/questions/1081828/…
-
Blaine about 8 yearsInteresting... The server is accesible and printable form a seperate windows vista computer. So either it's a problem with My computer, or with windows 10. Maybe by this point we should just try to solve the problem on this thread as it is probably an issue with the client, not the server superuser.com/questions/1081828/…
-
Blaine about 8 yearsWell, it's solved (sort of). Thank you so much for your help. Turns out, windows 10 doesn't like samba for some reason. Connecting to the printer using an http CUPS address allows me to print... weird, but I'll take it