Access local files from anywhere using btunnel

If you want to access your local files and folders from anywhere, then btunnel would be a very userful tool in your arsenal.

You might want to share files stored in hor local HDD or SSD or your home media server. Uploading them to any cloud or CDN server is not only time consuming but also have a huge cost overhead.

With btunnel, you can simply share your folders through a globally acessible https url.

Also, btunnel comes in with inbuild basic auth which gives you an additional layer of protection because even with the globally accessible url, no one can access that without username and password.

Let's dive into how to actually achieve this.


Before starting, you need two things -

  1. Register here to get an API key
  2. Download btunnel client for you OS

Running a file server

To serve a local directory DIR_PATH over the internet, use the "file" command. The default directory is the current directory ("."). This gives you a randomly generated url which is globally accessible through the internet.

Go to the directory where you have downloaded and extracted the btunnel client binary. Run the following command in your terminal (for *NIX such as linux and MacOS) -

./btunnel file --dir /home/username/ --key <API_KEY>

or (for Windows) -

C:\Users\user\Desktop\btunnel-dir> btunnel file --dir C:/Users/username --key <API_KEY>

The sample output of the above command is something like this -


  Name: -> John Doe                                                                                          
  Email: ->                                                                                    
  TimeOut: -> Never                                                                                              
  Web Monitoring: -> http://localhost:7140

    file -> /home/username/ Fri Feb  9 15:09:49 2024    

    file   2024/02/09 - 20:39:53 | 200 |     243.566µs | | GET      "/"                          
    file   2024/02/09 - 20:39:53 | 404 |      22.141µs | | GET      "/favicon.ico"               
    file   2024/02/09 - 20:39:56 | 200 |     105.788µs | | GET      "/Documents/"                
    file   2024/02/09 - 20:39:59 | 200 |     129.131µs | | GET      "/Documents/workspace/"      
    file   2024/02/09 - 20:40:05 | 200 |     132.999µs | | GET      "/Documents/workspace/Try/"  

  Press q or Esc to exit 

Now, if you open the shown url, you can viee and access your local files through a web based file browser -

share local file to internet

Protection with basic auth

To enable basic auth with btunnel, just use the --auth option as follows with your username and password seperated by a : like this username:password -

./btunnel file --dir /home/username/ --key <API_KEY> --auth uname:password

It is that easy.

This will serve your directory with a basic auth capability with username uname and password as password. This means, whenever someone tries to access the url, they have to authenticate themselves with the above mentioned username and password for the first time.

A screenshot of the authentication is shown below (in Ubuntu 22.04, Firefox browser).

basic auth