How to allow guest access in SAMBA

40,856

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.

Share:
40,856

Related videos on Youtube

Blaine
Author by

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, 2022

Comments

  • Blaine
    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
    Blaine about 8 years
    when executing the 2nd command i get "failed to find entry for user someusername"
  • Blaine
    Blaine about 8 years
    may 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
    scuba_mike about 8 years
    sorry, try sudo smbpasswd -a someusername
  • scuba_mike
    scuba_mike about 8 years
    Sharing a directory is no different than sharing printers as printers are, very simply put, files.
  • Blaine
    Blaine about 8 years
    that 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
    scuba_mike about 8 years
    Did you restart samba? After you change the smb.conf, you need to restart the service so that it reads the conf file again.
  • Blaine
    Blaine about 8 years
    Yes, i did restart samba
  • scuba_mike
    scuba_mike about 8 years
    Can you post the contents of your /var/log/samba/* file where * is the appropriate file name for setup?
  • Blaine
    Blaine about 8 years
    there'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
    Blaine about 8 years
  • scuba_mike
    scuba_mike about 8 years
    The 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
    Blaine about 8 years
    Alright. 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
    scuba_mike about 8 years
    I 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
    lorenzog about 8 years
    The answer here is correct: you need to issue sudo smbpasswd -a blaine as blaine 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
    Blaine about 8 years
    it 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
    Blaine about 8 years
    either 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
    Blaine about 8 years
    Interesting... 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
    Blaine about 8 years
    Well, 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