I would like to be able to access the files on my Ubuntu laptop from my Android phone and tablet. Ideally, I would want to do this over my own secure Wlan and then over sftp or Samba shares. Since there is no Wlan that is accessible to me where I want to do this, I want to create that Wlan network with the laptop's built in wifi or a Wifi USB stick. This Wlan should be accessible by ordinary Android devices.
Here is the problem: when choose "create new wireless network" in the network manager applet, the network created is NOT available in any of my mobile devices. I am told this is because it is an "ad hoc" network which is not supported by these devices.
There are some instructions on how to create managed networks (not sure if this is the correct term) but those look very complex and often differ among each other. Also, all of these instructions are for making the internet connection of the laptop available over Wifi - which I do not need. All I need is for the Wifi network to make the notebook files available, so the only host that needs to be accessible over this Wlan is the notebook.
Is there a (hopefully) easy way to just start such a WLan network? If not, would it be possible to achieve what I want with some other kind of hardware (other than a simple USB Wifi stick), so I can create a Wlan where my laptop is the only accessible host?
I think with the increasing number of mobile devices, and with both the mobile phones/tables AND the laptop having their Wlan hardware built right in, it is odd that there is no easy way to connect them directly and without the necessity that both devices have access to some other Wlan.
EDIT: I think this may be not, as suggested a duplicate, since the answer to the other question, as well as many other often slightly different recipes, try to share the internet connection of the computer that provides the access point, while I just want to access files on this computer or use services there, simply using the IP address. So what I was looking for is the easiest way to achieve this. I think I may have found a solution in the meantime which is less complex as the answer for the suggested duplicate, but I cannot seem to create an answer here.
Below are what I believe are the minimal steps to achieve what I wanted. For now, the steps only work for an additional Wifi USB stick, not the built-in Wifi hardware. I will edit this as I learn more ...
Install and set up hostapd
In order to make the Wifi hardware (the one built into the laptop or some additional Wifi USB stick) work in non ad-hoc mode, the hostapd software is necessary. Note that for this to work at all, the Wifi hardware needs to be supported by the hostapd software and the hardware needs to be able to support non ad-hoc mode.
sudo apt-get install hostapd
wlan1
or similar. The commandifconfig
will show all availble network interfaces.Create the config file
/etc/hostapd/hostapd.conf
(e.g. with the commandgedit /etc/hostapd/hostapd.conf
) with the following content where you replace<INTERFACENAME>
with the name found in step 2,<MYSSID>
with the name you chose for your network,<CODE>
with the two-letter code of your country (e.g. US),<MODE>
with the Wifi network mode (e.g. g) and channel with a valid channel number (e.g. 3). Alternately, the lines forhw_mode
andchannel
can be left out entirely. Replace<MYPASSPHRASE>
with a phassphrase you like (but avoid umlauts or accented characters).See http://linuxwireless.org/en/users/Documentation/hostapd for more information.
sudo hostapd -d /etc/hostapd/hostapd.conf
. This should start the Wifi network and it should be possible already to connect to this network from the mobile device: the network with the SSID you assigned should show up in the list and after entering the password, the device should connect to the network. However, the device will not get an IP address and so no real data transfer is possible yet. Terminate the command by pressingCtl-C
Install DHCP and set up the network
In order to actually transfer data between the mobile device and the laptop, the network must know which range of IP addresses it should use and a program is needed to assign IP addresses to any device that wants to connect.
sudo apt-get install isc-dhcp-server
to install the DHCP server.Edit the interface configuration file
/etc/network/interfaces
and add the following to the end:Edit the DHCP configuration file
/etc/dhcp/dhcpd.conf
and add the following to the end.If you know the MAC address of the mobile device and want assign a fixed IP address to it, you can add the following lines before the closing brace, replacing
XX:XX:XX:XX:XX:XX
by the MAC address. This will assign the fixed IP address 192.168.2.2:sudo ifup <INTERFACENAME>
sudo dhcpd -f -d <INTERFACENAME>
(this will keep running until you terminate with Ctrl-C and show log messages to the terminal)sudo hostapd -d /etc/hostapd/hostapd.conf
If all goes well you should now be able to connect from a mobile device to that Wifi network and the device should be assigned an IP address in the 192.168.2.X range.
Accessing Files and Services on the Laptop
Once the network is started, the mobile device should be able to access services running on the laptop (but not the internet). The easiest way to share files from the laptop is to create a Samba share for a directory on the network. This can be done by right-clicking on the directory icon and choosing "Sharing options", then check "Share this folder" and optionally assign some share name, the click "create share".
For android devices, there are several apps that can be used to access Samba shares, I use "ES File Explorer". In the ES File Explorer app, change to the "LAN Shares" tab and add a new server. In the "server" field, enter the IP address of the server, e.g. 192.168.2.1, then enter the Ubuntu userid and password and touch "OK". When you touch the server IP address, all the shares you created should be listed and from there you can copy files or whole directories to the Android device.
Another way to access files on the laptop which is also supported by the "ES File Explorer" app is
sftp
.I use the ES File Explorer to access files on my pc and nas server. ES uses SMB to connect to your pc via Wifi.
Using the Remote File Manager of ES you are also able to manage files on your phone from your computer.
EDIT Why don't you use a 10$ wifi router to establish your network? Or what's wrong with a good old cable to connect your mobile with the pc?
Your question is in fact two questions, that could be asked in two separate questions and answered separately.
1) How to setup a WiFi access point with an Ubuntu laptop?
I suggest you read the answer by @Err Hunter in this link. Please note to this comment: You must read the second source link if you are using Ubuntu14.04.
2) How to share files between my Ubuntu laptop and Android devices over above network?
Answer to this question has two parts:
Part 1: Share a folder on your laptop (Ubuntu):
This answer is the best guide I found for this purpose.
Part 2 (Main part of your question, I think): Access shared files
I offer "ES File Explorer" app. In the ES File Explorer app:
- Go to the Network tab - Select "LAN" - Press "+" icon in the bottom of the page no add new item - In the "Server" dialog, enter the IP address of the server, e.g. 192.168.150.1, then enter the Ubuntu Username and Password in appropriate fields and touch "OK". - A new Item is added under "LAN" category. - If you touch that item, all the shares you created should be listed and from there you can access files and directories from your Android devices.