Samba - Network Bridge across Linux and Windows

Friday, February 20, 2009

Samba - Network Bridge across Linux and Windows

SambaSuppose I have a Windows PC and a Linux Box in the network, how am I gonna transfer files across these?

You can upload to some online location and then download to the other box, or send mail and open it from the other box... these you can do if it makes you happy :)

Or you can connect using ftp, provided ftp daemon is running on the Linux Box.

One of the more convenient method is using WinSCP, it is a Windows client for SFTP and FTP, and I must say 'it is too easy to use'. See more about WinSCP...

But, this is never like opening the Linux directories in Windows Explorer just like local directories... and that is what Samba is for... and I am gonna explain how it is done...

This is for Fedora 6, but must work for most distributions with minimal changes... also I am gonna do it fully from CLI... so no mouse for you :) Also, some commands may need you to be root.

Install Samba

yum -y install samba
yum -y install samba-client
yum -y install system-config-samba

If yum install samba shows error about missing 'samba-common', just yum install samba-client first and then yum install samba. And it is ok even if you don't install system-config-samba, it is for the GUI Configuration Utility.

BTW, if you haven't already noticed, you will need a working internet connection to use yum :)

Install without yum

Download these rpms...

samba-client-3.0.23c-2.i386.rpm - Optional

Install the rpms...

rpm -Uvh samba-common-3.0.23c-2.i386.rpm
rpm -Uvh samba-3.0.23c-2.i386.rpm
rpm -Uvh samba-client-3.0.23c-2.i386.rpm

The order of installation may vary...

Configure Samba Server

So, you have installed Samba. Try testing the daemon by running service smb start. The server must start successfully.

Now, we are gonna configure it to be used by Windows.

The terms used (replace wherever seen):
- atoztoa : My username
- /home/atoztoa : The directory which I am gonna access. Note that I must have full access to this directory.
- atoztoa_win : The username I am gonna use from Windows when accessing the Linux Box.

We need to add a system user as a network user so that Samba can identify the user from the network.

smbpasswd -a atoztoa

This will add a new Samba user.

Open "/etc/samba/smbusers" in your favorite editor, I use vim.
vim /etc/samba/smbusers.

- Add the following line:
atoztoa = "network atoztoa_win"

Save and close the file. (I think Samba may work even without smbusers file...)

Now we will change the Samba Configuration file. Let's just make a backup :)
cp /etc/samba/smb.conf /etc/samba/smb.conf_bkp

Edit the file, vim /etc/samba/smb.conf

- Find the line:
workgroup =
Change the line to:
workgroup = [your windows workgroup]

- Find the line:
server string =
Change the line to:
server string = [description of the Linux Box]

- Find the line:
; security = user
Replace the line with these two lines:
security = user
username map = /etc/samba/smbusers

- Find the line:
wins support =
Change the line to:
wins support = yes

- Add new Directory Entry at the end of the file...
comment = ATOzTOA's Home
path = /home/atoztoa
valid users = atoztoa
writable = yes

Save and close the file.

Configuration is complete. Restart Samba Server Daemon...

service smb restart

If the service restarts successfully, then Samba is ready for use.

Configure the samba service to start automatically during bootup...

chkconfig --level 345 smb on

Accessing the Directory

From Windows, from run give \\[ip address of the linux box]. It will open the Linux Box and the Directories added to Samba will be listed. The name of the entry will be the name given inside [] in smb.conf. Open it giving 'atoztoa_win' and [linux password].

Also, add it as an entry using "Map Network Drive".

That's all :)

Any queries, feel free to ping back...


See also... » Backup Ubuntu Applications - Tutorial

» Command Search in Linux

ATOzTOA : Latest Headlines


Post a Comment