Debian/Ubuntu Tips and Tricks

Debuntu

Debian/Ubuntu Tips and Tricks

Samba: How to share files for your LAN without user/password

Posted by chantra on February 11th, 2007

This tutorial will show how to set samba to allow read-only file sharing for your LAN computers as guest (without be prompted for a password).
Because users won't be prompted for a user/password, this tutorial is meant to be installed in a LAN where all host are to be trusted.

There is many advantages of sharing files in a LAN. For instance, when you have a multimedia box (playing music, movies....) it is great to be able to access the music on that box from any machines in your LAN.

Let's get started. In the first place, you need to have samba installed.

$sudo apt-get install samba

Because we are going to make samba security insecure, make sure only your local network can access samba service. To do so, open and edit /etc/samba/smb.conf

$sudo vi /etc/samba/smb.conf

and set interfaces to lo and your local network interface. In my case: eth1.

interfaces = lo eth1
bind interfaces only = true

Now, it is time to smoothen samba default security by changing the security variable: security and make sure it is set to share instead of user and that guest account is enabled:

security = share
...
...
guest account = nobody

Now, we can create a share to be accessible to guest users:

[Guest Share]
        comment = Guest access share
        path = /path/to/dir/to/share
        browseable = yes
        read only = yes
        guest ok = yes

You can now test that your configuration is good using testparm:

$ testparm

If everything is fine, it is time to reload samba service to have your new configuration taken into account:

$sudo /etc/init.d/samba reload

That's it, anybody in your LAN can now access your share.

7 Responses to “Samba: How to share files for your LAN without user/password”

  1. Thank You. Thank you. Thank you. I've been troubleshooting samba not working for me for the past 4 days. and this guide fixed it all for me. Thank you very very much.

  2. A trick. If you still need security = user for other shares

    guest account = nobody
    map to guest = bad user

    will allow anonymous shares where you specify guest ok = yes (testing this out further but works so far.

  3. And also make sure that shared folder is under fully browsable path, eg. /home/share (and not buried under personal user account somewhere...)

  4. Hi, i have created account's to access shared drive with privilege's .Even though it was login with guest account.Could you please me solution to access with specified account?

  5. user = share is now depreciated and is ignored - as testparm will tell you.

    there is quite a good explanation at http://ubuntuforums.org/archive/index.php/t-1962617.html

    In essence to get the same effect:
    If you use "security = user"
    you must add "map to guest = Bad User".

    But if your windows username exists in samba then your password should match or you'll still be asked for it. Sounds like a security problem to me, to have your password kept by windows. You can remove your entry from samba to remain as guest, but then you may still want to log into your own share too ....

  6. I am still having an issues.
    1. I have shared several directories (Pictures, Videos, etc) so me, wife and kids can access them.
    2. I have my user directory (scott) also in smb.conf but it is not protected from othere access. This should be password protected. I did not encrypt home directories.

    How do I restrict access to scott files and not Pictures, Videos, etc?

    [global]

    workgroup = WORKGROUP

    server string = %h Server (Samba, Ubuntu)

    ####### Authentication #######
    server role = standalone server
    passdb backend = tdbsam
    obey pam restrictions = yes
    unix password sync = yes

    passwd program = /usr/bin/passwd %u
    passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
    pam password change = yes
    security = user
    guest account = nobody
    map to guest = bad user

    ########## Domains ###########
    ;[netlogon]
    [Pictures]
    comment = HDA Pictures
    path = /media/pictures
    browsable = yes
    guest ok = yes
    read only = no
    writable = yes

    [Videos]
    comment = HDA Videos
    path = /media/videos
    browsable = yes
    guest ok = yes
    read only = no
    writable = yes

    [scott]
    comment = Scott Space
    path = /home/scott
    readonly = no
    writable = yes
    force user = scott
    browseable = yes
    guest ok = no
    create mask = 0755
    ; valid users = scott
    valid users = %S
    directory mask = 0755

  7. A couple other things:
    This is after a new install of Ubuntu 14.04 server on headless HP MediaSmart Server.
    I execute the following after editing smb.conf
    > sudo /etc/init.d/samba reload;sudo restart smbd;sudo restart nmbd
    * Reloading /etc/samba/smb.conf smbd

    I created a ~/samba directory but did not add any files to it. Maybe I need to?

    Thanks in advance.
    Scott

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>