Tag Archives: sharing

Samba server and client configuration in Debian

http://www.debianhelp.co.uk/samba.htm
http://julien.herbin.ecranbleu.org/samba_client_howto/

Samba server configuration

apt-get install samba samba-client

Check an smb.conf configuration file for internal correctness.
testparm

Look what services are available on a server.
smbclient -L //server -U username

/etc/samba/smb.conf

[global]
workgroup = WORKGROUP
server string = %h server (Samba %v)
dns proxy = no
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
panic action = /usr/share/samba/panic-action %d
security = user
encrypt passwords = true
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
map to guest = bad user
usershare allow guests = yes

[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
guest ok = no
read only = yes
create mask = 0700

[disk]
path = /disk
browseable = yes
writeable = yes
comment = Shared data
guest ok = no
read only = no
create mask = 0775

[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
browseable = yes
read only = yes
guest ok = no

Synchronize Samba username with Linux
smbpasswd -L -a username (set a password)
smbpasswd -L -e username (enable user)

Example of a manual mount
mount -t smb //server/share /mnt/somedir

Example of automatic mount a startup
The first one is mounted read-only whereas the second one is mounted read-write. If you have need “user name/password” to authenticate, then add in the “” column "username=your_user_name,password=your_password,ro,user".

//server/share /mnt/somedir smbfs password=,ro,fmask=755,dmask=755
//server/share /mnt/somedir smbfs password=,fmask=777,dmask=777

HOWTO: NFS Server/Client

http://ubuntuforums.org/showthread.php?t=249889

I found using NFS just as easy if not easier than using Samba for sharing between a few of my Unix based systems. In order to share a folder it only required a single line in a configuration file under /etc/exports, and a single line under /etc/fstab on the client to mount the share on each client at boot.

Install NFS Server Support

sudo apt-get install nfs-kernel-server nfs-common portmap
When configuring portmap do =not= bind loopback. If you do you can either edit /etc/default/portmap by hand or run:

sudo dpkg-reconfigure portmap
sudo /etc/init.d/portmap restart

You want to start the idmapd daemon. It is NOT only needed for NFSv4.
/etc/default/nfs-common

NEED_IDMAPD=YES

Editing /etc/exports
the /etc/exports file is used for creating a share on the NFS server

invoke your favorite text editor or
sudo nano /etc/exports

For Full Read Write Permissions allowing any computer from 192.168.1.1 through 192.168.1.255

* /files 192.168.1.0/24(rw,no_root_squash,async)

Or for Read Only from a single machine

* /files 192.168.1.2 (ro,async)

My personal choice is:

/disk            192.168.1.0/27(rw,no_root_squash,async,no_subtree_check,crossmnt,fsid=0)

sudo /etc/init.d/nfs-kernel-server restart

Also aftter making changes to /etc/exports in a terminal you must type
sudo exportfs -a

Install NFS client support
sudo apt-get install portmap nfs-common

Mounting manually
Example to mount server.mydomain.com:/files to /files. In this example server.mydomain.com is the name of the server containing the nfs share, and files is the name of the share on the nfs server

The mount point /files must first exist on the client machine.

cd /
sudo mkdir files

to mount the share from a terminal type

sudo mount server.mydomain.com:/files /files

Note you may need to restart above services:

sudo /etc/init.d/portmap restart
sudo /etc/init.d/nfs-common restart

Mounting at boot using /etc/fstab
Invoke the text editor using your favorite editor, or
sudo nano /etc/fstab

In this example my /etc/fstab was like this:

server_hostname:/files /files nfs rw,rsize=8192,wsize=8192,timeo=14,intr

You could copy and paste my line, and change servername.mydomain.com:/files, and /files to match your server name share name, and the name of the mount point you created.
It is a good idea to test this before a reboot in case a mistake was made.
type
mount /files
in a terminal, and the mount point /files will be mounted from the server.

If you want to change permissons recursively on files and folders, you can run:
find /files \( -type d -exec chmod 775 {} \; \) -o \( -type f -exec chmod 664 {} \; \)

And do not forget, the NFS mount is originated from the server hence the directory permissions on the server will be used for client. The mount points do not follow the local server’s permission as they are not local.