2

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.

4
  • user68186: no that is the whole point of my question! I know how to connect my android device to my laptop if they are both connected to some existing wlan that is provided by some wlan router. But I want to connect them without the necessity to rely on such a network and instead create the network directly on my laptop, similar to what the "create new wireless network" option in the network manager does but in a way that works with android (and other) mobile devices.
    – jpp1
    Feb 13, 2013 at 23:27
  • The short answer is, can't be done unless you either root the Android device and mess with it's internal to make it recognize Ad hoc network. Or mess with Ubuntu's internals to create an (non-ad hoc) access point.
    – user68186
    Feb 14, 2013 at 0:31
  • user68186: my question is about how to make Ubuntu create an non-ad hoc access point. Given that there are now millions of mobile phones, tablets and other devices and that the Wifi hardware is present on most laptops it is hard to believe that there should be no way to do this in Ubuntu. It seems like a perfectly natural functionality to offer to users.
    – jpp1
    Feb 14, 2013 at 11:25
  • I have voted to re-open this post so you can add your answer.
    – Seth
    Feb 16, 2013 at 2:01

3 Answers 3

1

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.

  1. Install software with sudo apt-get install hostapd
  2. Find the name of the network interface that corresponds to the Wifi hardware. For an additional Wifi USB stick this may be wlan1 or similar. The command ifconfig will show all availble network interfaces.
  3. Create the config file /etc/hostapd/hostapd.conf (e.g. with the command gedit /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 for hw_mode and channel can be left out entirely. Replace <MYPASSPHRASE> with a phassphrase you like (but avoid umlauts or accented characters).

    interface=<INTERFACENAME>
    driver=nl80211
    logger_stdout=-1
    logger_stdout_level=0
    ssid=<MYSSID>
    country_code=<CODE>
    hw_mode=<MODE>
    channel=<CHANNEL>
    macaddr_acl=0
    auth_algs=1
    ignore_broadcast_ssid=0
    wpa=2
    wpa_passphrase=<MYPASSPHRASE>
    wpa_key_mgmt=WPA-PSK
    wpa_pairwise=TKIP
    rsn_pairwise=CCMP
    

    See http://linuxwireless.org/en/users/Documentation/hostapd for more information.

  4. Run the command 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 pressing Ctl-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.

  1. Use command sudo apt-get install isc-dhcp-server to install the DHCP server.
  2. Edit the interface configuration file /etc/network/interfaces and add the following to the end:

    iface <INTERFACENAME> inet static
    address 192.168.2.1
    netmask 255.255.255.0
    
  3. Edit the DHCP configuration file /etc/dhcp/dhcpd.conf and add the following to the end.

    subnet 192.168.2.0 netmask 255.255.255.0 {
      range 192.168.2.3 192.168.2.10;
      option broadcast-address 192.168.2.255;
      option routers 192.168.2.1;
    }
    

    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:

      host device1 {
        hardware ethernet XX:XX:XX:XX:XX:XX;
        fixed-address 192.168.2.2;
      }
    
  4. Bring up the the interface with the command sudo ifup <INTERFACENAME>
  5. Start the DHCP server with the command sudo dhcpd -f -d <INTERFACENAME> (this will keep running until you terminate with Ctrl-C and show log messages to the terminal)
  6. Start the managed network with the command 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.

0

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?

4
  • I know how to use ES File Explorer - the question is about how to use the Wifi hardware on my laptop to create my own Wifi network which I can use to from my android device. As I said, the network that is created by the "create new wireless network" option in the Ubuntu network manager is known NOT to work with practically all mobile phones. So the question is: how to create a network instead that DOES work? I do not use a cable because the only way to use all my devices over USB is using MTP and that does not work properly either and if it does, not as flexibly as ES File Explorer over Wifi
    – jpp1
    Feb 13, 2013 at 23:29
  • Yeah I didn't see the problem. Did you try to offer a network using your mobile? If this doesn't work you could try Bluetooth File Transfer a file browser that uses bluetooth to transmit the files and encrypts the communication for you.
    – Phidelux
    Feb 14, 2013 at 7:33
  • Avedo: unfortunately, creating the network on the mobile/tablet (tethering) is not possible for many mobiles and especially tablets. I know there are alternatives (but usually clumsy ones) but my question is really about how to create a non ad-hoc access point on an ubuntu laptop, or why such a simple thing (which can be done as you pointed out, by many, often cheap, android phones) cannot be done with Ubuntu.
    – jpp1
    Feb 14, 2013 at 11:31
  • I just remembered that I saw an article on that topic ... Have a look at this Techmite article. A more complex solution was mentioned here at askubuntu.com in this thread.
    – Phidelux
    Feb 14, 2013 at 11:35
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .