Wednesday, July 23, 2008

Samba Client on Linux (Windows Network Folders)

Samba Client

By : Julien Herbin Email : jam@ecranbleu.org
Don't hesitate to contact me in case you need any information. Please inform me of any mistake I may have done.
Last modified : 2004-24-01

This Howto will show you how to browse a Microsoft Windows shared directory and then mount it on your local Linux filesystem using SAMBA (http://www.samba.org/).
This Howto was written for the Debian Linux distribution, because packages management and dependencies is easy and commonplace through the APT command. It doesn't mean that the configuration won't work with another Linux distribution, since packages to install should be the same, but some configuration files may be located in another directories of your filesystem.



Installation
Installing the packages
First login as root in order to get the required packages.
You need to install both samba-common and smbclient packages. If you are using a Debian distribution, then type in :


$ apt-get install smbclient


Maybe another packages will be installed since smbclient depends "samba-common, libc6, libcupsys2, libncurses5, libpam0g, libreadline4".
Others will have to get those package installed another way (RPM for RedHat and Mandrake for instance).

If you indent to mount windows shares directly on your filesystem, install the smbfs package. Note that to do such a thing, you will need to include "SMB Network FilesSystem" to your kernel or to your modules. Just check the "SMB file system support" item in the "Filesystem => Network Filesystem" menu. Then rebuild you kernel and reboot, or rebuild you modules and that's all ;).
For Debian users, then type in :


$ apt-get install smbfs


Others will have to get this package installed another way.



Configuration

Now that install is complete, you should be asked your desired Workgroup / Domain Name. You should enter here the same workgroup (usually "mshome" by default on win2k and win XP).

Then you will be asked if you want to use password encryption. Answer yes.

Finally, answer yes to use WINS settings from DHCP if you have a Windows DHCP server running on a computer of your network (note that the package "dhcp3-client" should be installed on you system to get this feature work correctly).


Altering the configuration file

In case you need to change the configuration you setted up just after installation, just edit the "/etc/samba/smb.conf" file.



Doing some tests

Shares directories browsing
Let's check that your installation is successfull and do a first browsing test.
My computer "Fraise" runs a Windows XP Home Edition with the guest login on. So, i don't have to worry about a username/password to get to access my shared directories. If you do need a username/password, then add " -U your_username". Your password should be asked when press enter.

$ smbclient -L network_name_of_your_windows_computer

If your computer is called "fraise", then enter :

$ smbclient -L fraise

A password will be asked to you. If you set one on your Windows computer, then enter it now.

The result should look like the following :


[15:03:24][jam@cerise] ~$ smbclient -L fraise
Password:

Sharename Type Comment
--------- ---- -------
IPC$ IPC Distant IPC
print$ Disk Printers Drivers
D Disk
hpdeskje Printer hp deskjet 845c
UtilZ Disk My read only shared directory
Upload Disk My read/write shared directory

Server Comment
--------- -------

Workgroup Master
--------- -------


Example of a manual mount
Now, lets assume the package "smbfs" is correctly installed and your kernel or your modules include the "smbfs driver". We are going to mount the "UtilZ" and the "Upload" directories from the computer called "Fraise".


cd /mnt
mkdir smb_UtilZ_on_Fraise
mkdir smb_Upload_on_Fraise


Now try :

mount -t smb //fraise/UtilZ /mnt/smb_UtilZ_on_Fraise

if it says unknown filesystem (as it says on Fedora 6) try:

mount -t cifs //fraise/UtilZ /mnt/smb_UtilZ_on_Fraise


Note that if you compiled "smb file system driver" as a module, it should load automaticaly :



[13:08:19][root@cerise] /mnt# lsmod
Module Size Used by
smbfs 68760 2



Automatic mount a startup

If the last step was successfull, you should not meet any kind of problem here. Here are the lines to add to your "fstab" configuration file (usually located in "/etc"). The last two lines are responsible for the two shared directories mountage on startup.
The first one is mounted read-only whereas the second one is mounted read-write. If you have need "user name/password" to authentifiate, then add in the "" column "username=your_user_name,password=your_password,ro,user".


//fraise/UtilZ /mnt/smb_UtilZ_on_Fraise smbfs password=,ro,fmask=755,dmask=755 0 0

//fraise/Upload /mnt/smb_Upload_on_Fraise smbfs password=,fmask=777,dmask=777 0 0


if it says unknown filesystem (as it says on Fedora 6) or dosent work try:


//fraise/UtilZ /mnt/smb_UtilZ_on_Fraise cifs password=,ro,fmask=755,dmask=755 0 0

//fraise/Upload /mnt/smb_Upload_on_Fraise cifs
password=,fmask=777,dmask=777 0 0


You can set up your own options to give permissions on files and directories. For example, it is possible to assign au uid or a gid to the files and directories
Type "man smbmount" to get more details on options



GUI Browsing
If you feel like using a GUI to manage your Samba mounts, you can use the program LinNeighborhood (http://www.bnro.de/~schmidjo/index.html).

Run as root :


$ apt-get install smb4k


To start the program, type in your favorit X console :

$ smb4k

Please refer to program's homepage to get information.

2 comments:

Anonymous said...

Can anyone recommend the top Managed Service tool for a small IT service company like mine? Does anyone use Kaseya.com or GFI.com? How do they compare to these guys I found recently: N-able N-central remote support manager
? What is your best take in cost vs performance among those three? I need a good advice please... Thanks in advance!

nick jones said...

thanks for sharing information,good blog..

Passive Networking

Structured Cabling