3

I am tethering my laptop from my phone.

Is there a way to access the file system on my laptop from the mobile phone while tethering? I would for example like to be able to access image files from my laptop on the phone. (Additional info: I do not have wifi access on the phone and I don't want to use 3G for transferring files locally).

Laptop: Ubuntu 16.04 LTS

Phone: Samsung Galaxy S5

5
  • 15.10 is an old release so if it is not working you will likely have to at least upgrade to 16.04 – Panther Nov 18 '17 at 10:45
  • How do you mean 'tethering the laptop from phone' ? Doesn't this means that you will have a outbound connection in laptop from the phone (3g) – fugitive Nov 18 '17 at 11:40
  • Updated. Still need an answer – Vesa Nov 18 '17 at 15:31
  • @Vesa 16.10 is also out of support. Currently supported releases are 14.04 LTS, 16.04 LTS, 17.04 and 17.10. – pomsky Nov 18 '17 at 17:43
  • Updated. Still need an answer. – Vesa Nov 19 '17 at 6:37
1

Use Python module to run a basic HTTP server and use a web browser on mobile phone to access the localhost PC via USB tethering.

Overview of setup and usage

A mobile phone is connected to localhost PC via a USB cable.

  • Setup on mobile phone (USB tethering is enabled)
  • Setup on localhost PC (see Part A.)
  • Access from mobile phone (see Part B.)

When user has finished access, go to localhost PC and press Ctrl+C to stop the HTTP server that is running in the terminal. Or simply closing the terminal may terminate the process as well.

Part A: Setup on localhost PC

Ensure that Python is installed on the localhost PC (Run python --version in a terminal to check the version, which will affect step 3).

  1. Open a terminal

  2. First, check the IP address of localhost PC using ip or ifconfig command (whichever works). The following example output shows 192.168.XX.YYY is the IP address that has been assigned to a localhost PC via USB tethering.

    $ ip addr show usb0 
    3: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether **:**:**:**:**:** brd ff:ff:ff:ff:ff:ff
    inet 192.168.XX.YYY/** brd 192.168.XX.ZZZ scope global usb0
       valid_lft forever preferred_lft forever
    inet6 ****::****:****:****:****/** scope link 
       valid_lft forever preferred_lft forever
    
    $ ifconfig usb0
    usb0      Link encap:Ethernet  HWaddr **:**:**:**:**:**  
              inet addr:192.168.XX.YYY  Bcast:192.168.XX.ZZZ  Mask:255.255.255.0
              inet6 addr: ****::****:****:****:****/** Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              ...
    
  3. Then, start an HTTP server using Python module with any available port number i.e. 31415 (Easy to remember as 'pi'). The following example shows http.server module is used for Python 3, otherwise use SimpleHTTPServer module for Python 2.

    $ python -m http.server <port_number>
    Serving HTTP on 0.0.0.0 port ***** ...
    

Additionally, if localhost PC has enabled firewall, add a new rule to allow incoming connection from the port number and IP address (This would be another set of question and answer). Else temporarily disable firewall would just work for simplicity in exchange of low security.

Part B: Access from mobile phone

Ensure that USB tethering remain enabled; No further configuration.

  1. Open a web browser

  2. Go to http://192.168.XX.YYY:<port_number> in which 192.168.XX.YYY is the IP address used by localhost PC and <port_number> is any available port number on localhost PC.

  3. The web browser will show Directory listing of current working directory, which by default is Home directory of current user.

User can now access any files and directories in the current working directory for browsing and download purpose.

Limitation and compatibility

An HTTP server will allow read-only access, which is good enough for browsing and download purpose. User will not be able to modify files on the localhost PC. Should user need both read and write access, then use other method (Perhaps using SFTP or SSH, which I do not know).

The HTTP server method will work as long as USB tethering is enabled (IP address is known), regardless of Airplane Mode or Cellular Data is turned on or off. Likely work for mobile phones with any Android version (not sure for other mobile operating systems).

Tested using Python 2.7 and Python 3.4, with UFW enabled and disabled on Xubuntu 14.04 and USB tethering enabled on Android 7.1.1.

References

Related posts on SE network

0

Here my solution.

Making

sudo /sbin/ifconfig

then looking for

enp0s20u2: {...}

that includes the following property:

inet 192.168.xx.xxx

Was the good IP adress to look for in my case.

I have then connected to my computer's localhost from my mobile phone in tethering mode by entering in my mobile'phone URL's bar, the following adress:

// where PORT is effectively the computer localhost's port number 
// on which you want to connect.
inet 192.168.xx.xxx:{PORT}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.