Aug 7, 2018

Tutorial: Creating a Home File Sharing Network over WiFi between Linux and Androids using SSH/SFTP

Power users are more and more moving away from the Microsoft and Apple ecosystems in the digital age as they prefer more privacy and control over forced upgrades, pricey customer support and planned obsolescence.

**********
Update on 2019-10-28:

ES File Explorer is no longer recommended for file transfer on Android and perhaps not even available on the Play Store. You can either use an alternative such as Solid Explorer with similar features, or use an older version of ES File Explore from APKMirror which works well without all kinds of adware and bugs.
**********

As a result, the typical hardware they own aren't Macbooks and iPhones/iPads, but rather a combo of Ubuntu laptop and android smart-phones/tablets. Now, the typical way of file sharing between linux and android is through USB cable which seems both hassle-some and inefficient. But if both your linux system and android devices are accessing the internet through a WiFi access point (or even connected through WiFi and accessible to each other), you can easily create a shared file-server out of your linux system using SSH/SFTP.

1. Setup a WiFi access point with IP Address Reservation


All you need for this to happen is that the devices should be connected on a WLAN and the linux system should preferably be assigned a static private IP (such as 192.168.1.2) by the DHCP reservation on the WiFi. Personally, I use the Jiofi 4G router to access the internet from my devices, but this tutorial is applicable to any WiFi router as long as it supports DHCP reservation in its configuration (to ensure an unchanging IP Address at least on the linux system):





In above setup, for example, the Ubuntu laptop is assigned a fixed IP of 192.168.1.2 in the local network. This helps your smart-phone or tablet to access it using SSH/SFTP.

2. Install SSH on your Linux system


On Ubuntu systems, its as easy as:

sudo apt install ssh.

This will install the openssh server which is the default linux implementation of ssh server. Leave the configuration defaults as they are sufficient for home use. But if you want to harden security by changing the default port, etc., refer to this openssh configuration guide, but that's generally only required on production machines. For a home setup, the defaults should be more than sufficient.

3. Install ES File Explorer (or a similar SFTP client) on your Android device


Once openssh is installed on your linux system and all your devices are connected to the WiFi access point, all you have to do is install an SFTP client on your Android device. ES File Explorer is just one file manager app with SFTP support, there are many others too such as Root Explorer and AirDroid. I just use ES because I'm familiar with it and its very easy to use:




Of course, if the linux user has sudo/root privileges, you may feel uncomfortable to use that login from other "remote" systems. Hence, you can create a new non-sudo linux user for this and assign it permissions to only specific files/folders that you want:

sudo useradd -m -d /home/tudor tudor
sudo passwd tudor
 

The first command creates a new user called tudor and second command assigns it a password. Now, you can do a "test login" of the newly created user by running:

sudo -i -u tudor

You can thus check what all folders are accessible to this new user. The same will be accessible when this user logs in through SFTP from an android device.

If you want a particular folder to be accessible to this new tudor user, you can do it as thus:

sudo chgrp -R tudor /path/to/folder
chmod -R g+rwx /path/to/folder

Above command recursively adds the tudor group to your selected folder (chgrp) and also ensures that the group has full permissions for it (g+rwx).

Once you do these steps, you are ready to start the ES File Explorer app, add a new entry for the linux system by going to Tools->Network->New (Tap Plus button) and selecting SFTP from the list.

2 comments:

Unknown said...

>more privacy
>android
>ES File Explorer
Wut ?

Anonymous said...

Yes, but there are very few SSH clients available on Android and ES is just one of them. I know ES has become more intrusive in last few versions, but the older versions are pretty usable and ad-free too.

As for Google's general telemetry, you don't have to worry as its anonymized. Besides, other companies like Microsoft and Apple do that too, so there is no escaping that anyway.

Privacy is always relative, not absolute!

Post a Comment