Samba Shares


Install Samba Server on Ubuntu

information via: http://www.howtogeek.com/howto/ubuntu/install-samba-server-on-ubuntu/

If you want to share files between your Ubuntu and Windows computers, your best option is to use Samba file sharing.

To install, first open a terminal window and enter the following command:

sudo apt-get install samba smbfs

We’ve got samba installed, but now we’ll need to configure it to make it accessible. Run the following command to open the configuration file, substituting your editor of choice:

sudo pico /etc/samba/smb.conf

Find this section in the file:

####### Authentication #######

# “security = user” is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba-HOWTO-Collection/ServerType.html
# in the samba-doc package for details.
; security = user

Uncomment the security line, and add another line to make it look like this:

security = user
username map = /etc/samba/smbusers

This will set Samba to use the smbusers file for looking up the user list.

Finallly, add these two lines to your smb.conf:

[global]

null passwords = yes
map to guest = Bad User

The first tells Samba that null passwords are OK. The second that non-recognized users (which is what any user who doesn't have an account on your Ubuntu box will be) should be silently mapped to Guest (nobody).

This allows a non-authenticated Windows box to list the shares advertised as browseable by Samba. When the user attempts to connect to a share, Samba evaluates their credentials (in this case, Guest), and either allows them access, or prompts for a new user name/password. You can also always prevent shares from being listed by marking them as browseable = no.

You do sacrifice a little security for this convienince: anyone with access to your Samba server can now list your browesable shares and connect to any share that allows guest access. Samba isn't designed to face the Internet so all the normal rules for not doing that still apply. See the much more extensive Samba HOWTO (http://ubuntuforums.org/showthread.php?t=202605) for Ubuntu for general setup.

Next make sure that nobody is enabled in Samba's backend:

  • $ sudo smbpasswd -n nobody
  • $ sudo smbpasswd -e nobody

The first command creates the nobody account with a null password. The second enables this account. See this bug report (https://bugs.launchpad.net/ubuntu/+source/samba/+bug/39717) for more information. It took me awhile to track that down, but if I knew what I was doing it might have been faster. 😉

System user must be created first

:information via: http://ubuntuforums.org/showthread.php?t=839414


$ sudo useradd USERNAME –shell /bin/false

This assumes you create the SHARES folder and it is not the normal Linux /home.

Here's what I do to create and authorize each user of the SAMBA shares:

In, for example, the /home directory… to add a user called "USERNAME":

  • $ cd /shares/users
  • $ sudo mkdir USERNAME
  • $ sudo useradd -d /shares/users/USERNAME -s /bin/false -r USERNAME
  • $ sudo passwd USERNAME (then enter new UNIX password twice)
  • $ sudo smbpasswd -a USERNAME (then enter new SMB password twice)
  • $ sudo chown USERNAME USERNAME
  • $ sudo chgrp USERNAME USERNAME

Repeat for each user you wish to add to SAMBA.


System nobody must be enabled:


information via: http://ubuntuforums.org/archive/index.php/t-490168.html
For your shares that you want public users to access. But it still doesn't work. Check your /etc/shadow file with sudo cat /etc/shadow to see if you have a nobody account. You should.

Create a Samba User

There are two steps to creating a user. First we’ll run the smbpasswd utility to create a samba password for the user.

sudo smbpasswd -a <username> Completed above

Next, we’ll add that username to the smbusers file.

sudo gedit /etc/samba/smbusers

Add in the following line, substituting the username with the one you want to give access to. The format is <ubuntuusername> = “<samba username>”. You can use a different samba user name to map to an ubuntu account, but that’s not really necessary right now.

<username> = “<username>”

Now you can create samba shares and give access to the users that you listed here.

You may want the graphical version (don't know how it works yet)

Installing Samba Server confiuration tool:information via:http://www.unixmen.com/linux-tutorials/1060-how-to-configure-samba-using-a-graphical-interface-in-ubuntu

If on desktop Ubuntu or wish to have web interface


Now install the graphical interface System-config samba ( part may already be installed)


sudo apt-get install samba samba-common

sudo apt-get install system-config-samba

SWAT:From the application screen, install swat, Sambe Web Admin Tool (not a hugh, help but does with validation)
Access via: http://localhost:901/
Share Ubuntu Home Directories using Sambainformation via: http://www.howtogeek.com/howto/ubuntu/share-ubuntu-home-directories-using-samba/
Samba Server allows you to share the home directories of users automatically. This can be useful so that you don’t have to manually create every share for every user.

First, make sure that you’ve installed Samba server.

Share directories

To share the home directories, open up smb.conf with the following command:

sudo gedit /etc/samba/smb.conf

uncomment lines refering to CDROM

sudo gedit /etc/fstab
/dev/scd0 /cdrom iso9660 defaults,noauto,ro,user 0 0


Find this section of the file, and make it match the following:

Share Definitions

# Un-comment the following (and tweak the other settings below to suit)
# to enable the default home directory shares. This will share each
# user’s home directory as \\server\username
[homes]
comment = Home Directories
browseable = yes

# By default, \\server\username shares can be connected to by anyone
# with access to the samba server. Un-comment the following parameter
# to make sure that only “username” can connect to \\server\username
valid users = %S

# By default, the home directories are exported read-only. Change next
# parameter to ‘yes’ if you want to be able to write to them.
writable = yes

Always remember to test:

$ sudo pico /etc/samba/smb.conf
$ testparm
Restart:

$ sudo restart smbd
$ sudo restart nmbd


Validate:Check to see if the shares are present:

apt-get install smbclient

smbclient -L localhost


Now you should be able to map a drive on windows using the following share format:

\\ubuntumachine\username

For example, if the Ubuntu machine is named ubuntuserv, and the username is geek, your share path would be \\ubuntuserv\geek


Samba documentation:http://us5.samba.org/samba/docs/man/manpages-3/smb.conf.5.html
Directory/File Mask
http://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html
Create shares:Shares should be in the /srv directory structure:
/srv/share/public
# A publicly accessible directory, that can be read from

browseable = Yes
[public-read]
comment = Guest access share
path = /srv/shares/public
read only = yes
locking = yes
guest ok = yes
public = Yes
available = yes
writable = no
browseable = Yes
;[public]
; comment = %h Shared Public Directory
; path = /srv/shares/public
; force directory mode = 0777
; force create mode = 0777
; force group = nobody
; force user = nobody
; public = yes
; writeable = yes
; read only = no

(0) cd /srv
(1) sudo mkdir shares
(2) sudo chown -R nobody.nogroup /srv/shares
(3.1)
or (3.2) sudo chmod -R 0777 /srv/shares
(4) sudo mkdir public
(5) ls -l (to validate)

Un-install

if things go bad: $ sudo apt-get –purge remove smbfs
$ sudo apt-get –purge remove samba
–purge deletes all files not just the app.
also remove SWAT
SAMBA
https://bbs.archlinux.org/viewto[pic.php?id=45423

http://www.howtogeek.com/howto/ubuntu/share-ubuntu-home-directories-using-samba/
http://www.ubuntugeek.com/howto-setup-samba-server-with-tdbsam-backend.html
My /etc/samba/smb.conf file for reference:smb.conf (15.22 kb)

fstab (774.00 bytes)

smb.conf.save.zip (14.99 kb)

[A_KYC_PROD]
comment = KYC PROD SAMBA
browseable = yes
writable = yes
path = /data/samba/kyc
guest ok = no
vfs objects = full_audit
full_audit:failure = none
full_audit:success = mkdir rename unlink rmdir open pwrite
full_audit:prefix = %u|%I|%m|%S
full_audit:facility = LOCAL7
full_audit:priority = NOTICE


Tag Cloud