One file, many devices : Wireless LAN tutorial

All of us, I repeat, all of us have gone through the situation where we have our favorite stash of images, videos, music etc. on our PC and we need them on another device. It can be an android phone/ tablet, an iPhone/ iPad or another PC or Mac on your home network if you wish. Until now, what most of us did was throw an SD card on the main machine, copy the files, and put them on our desired device. Well that's past (er, this ain't new but most of us were unaware, so...) and if your devices are on the same network via LAN, its a breeze. You can access your main machine's contents on any of your device "wirelessly" without consuming an itty bit of storage. Sounds cool? Lets begin.


What we are going to do is set up a local server on our primary machine where all the desired files are stored. The software protocol to be set up is called Samba or SMB. Samba is the standard Windows interoperability suite of programs for Linux and Unix. Samba is Free Software licensed under the GNU General Public License, the Samba project is a member of the Software Freedom Conservancy.
Throughout this process, I am going to use an Ubuntu 17.04 desktop as my primary machine. If you are on windows, well, save that for another day.

Download Samba
On Ubuntu:
sudo apt-get install samba

On Fedora:
sudo yum -y install samba samba-client
sudo yum -y install system-config-samba

Reboot your system.

Configure Samba
A lot of online tutorials show you how confire samba from scratch, with an advanced us of the command line. Here, we are going to use the command line the least we need.

Keep in mind, all the Samba configuration files are stored in the path: /etc/samba

Head over there via command line or file manager. You will find initially two files in the folder, namely: gdbcommands, smb.conf

Among these, smb.conf is the one which we are going to tweak. Give yourself Administrator access and rename smb.conf to smb.conf.sav. Now, when ever the server accesses these files, it will automatically skip the original smb.conf file.

Now, open a text editor to create a new smb.conf file. Add the contents-

[global]
server string = Any server name of your choice
workgroup = What you want to name your server workgroup. Default is WORKGROUP
netbios name = Your Linux PC name (this is what appears after the @ in the terminal)
security = user
encrypt passwords = yes
guest account = nobody
name resolve order = bcast host
include = /etc/samba/smbshared.conf

Here's a look at my configuartions,


And here's how to find the PC name and the username from the terminal,


Save the new smb.conf at /etc/samba

Now, we need to create the SMB configuration file through which your server will access the desired folder on your main machine. In my case, I want my server to access my Home folder because all my Music, Movies, Documents and Images are in that directory (or "partition").

Again, open a text editor. The new file will be named smbshared.conf. Add the contents-

[Home]
    comment = Linux File Server Share
    path = Path to the home folder
    browsable = yes
    guest ok = yes
    read only = no ("yes" if you want read-only access)
    available = yes
    public = no
    writable = yes ("no" if you want read-only access)
    valid users = Your Linux username (this is what appears before the @ in the terminal)

If you want your server to access a different folder, its simple. First, [Your Folder Name]. Second, find the path to your desired folder. An easy way is to simply drag and drop the folder from your file manager on your terminal. You will get something like '/the/path/to/your/folder'. Copy the text within the quotes and paste it in the path = section of the smbshared.conf file. Mine looks like this,


Save the smbshared.conf at /etc/samba too.
Now, we have to set the username and password for the SMB server. Remember, Samba uses a different username and password from your Linux machine. But for your convenience, you can set the same username and password as your PC. It is up to you.
Open up your terminal and make sure you are in your root directory. To be on the safe side, type cd and press Enter.

Type the following,
sudo smbpasswd -a username (where "username" is any username you choose)

Samba will ask for your password, so be carefull on what you enter.

After the password for the respective username is set, we move on to the final step. Here we need to create another file called smbusers which stores the usernames. Open up your text editor once again and add the following-

username = "username

Look at mine,

 
Save the smbusers at /etc/samba again.

Okay, so the basic steps to set up an SMB LAN server ends here. But after settings things up, you still may run into some complications. For example, if you have a firewall set up, it may block your samba server. If you are using the Uncomplicated Firewall or UFW on your machine, simply fire up the terminal and enter the following-

sudo ufw allow Samba

You will see some confirmation messages. That's it. You are ready to go by now. You just need to restart the Samba by entering,
sudo service smbd restart
In my case, this did not work so I had to reboot my system.

After your machine reboots, you can find your connected folders under the network section of your file manager. Open the folder, enter the username and password and you will be connected. Any other machine on the same LAN network will have your Samba server visible by now and can connect by doing the same. You can now access your files stored on your main linux machine on the other machines on you local network.


Accessing files from Android (or iOS)
Most of us today have an android device, be it a smartphone or a tablet. If you want to access the files on your samba server from your android device, download the ES file explorer from the PlayStore.

Once downloaded and installed, head over to the network tab in the ES menu. Among the listed options, you will find one named LAN. Enter LAN and tap the scan symbol. Once scanning is done, your Samba server will pop up and you can once again access your files by entering your username and password. You can stream any music or video on your mobile device, directly from your main machine via the Samba server. Copying files to and from your PC to your Android and vice-versa just got much more easier. Cheers to Samba!


And there you have it, all your files on one secure local server, completely accessible by all your local devices. Hope you enjoyed our small, erm, big tutorial on SMB Servers. Stay tuned for more until then, have a nice day. Peace.

More from Ask Us Junkies

The Best of E3 2017
Apple WWDC 2017
Essential Home: Replacement for Google Home?

No comments:

Powered by Blogger.