Fun stuff with Keybase

Share to KBFS on Android

This is a bash script I wrote that uses Termux and its Android api to allow you to send files from your Android device to KBFS using your device's 'share' menu. I wrote this mainly because (at the time of this writing) you can only upload certain file types (images and videos, I believe) from your mobile device to your KBFS, and I've seen a lot of people asking when Keybase will allow more filetypes.

It takes a little bit of setting up, but it's not too bad, and once you've set it up it should be pretty straight forward to use. I'll walk you through setting it up here.


Before we begin, you need to make sure to have both Termux, and the Termux:API apps installed on your phone. You can get them from either the Play Store, or F-Droid, but you need to make sure that you get them both from the same place.

Install Dependencies

Once you have Termux and the Termux:API installed, there are a few packages you need to install inside Termux. Termux gives you a Linux environment on Android, and Termux packages are installed with the APT package manager. If you've used Debian or Ubuntu you will likely already be familiar with the package manager. Termux provides a pkg command, which is a wrapper for APT. As a side note, Termux:API is just a plugin for Termux that allows Termux to access certain parts of the Android system, but it's not an app that you will see in your app drawer, so from here on, we don't need to worry about Termux:API as long as it's installed (although in a second we're going to install the termux-api package, which is just a collection of bash scripts that lets you interact with the Android system through Termux... you don't have to worry about any of this if it's confusing at all, just follow along with my instructions).

Open Termux and run the following command:

$ pkg install termux-api jq expect keybase kbfs curl

Log into Keybase

Before you run this script for the first time you will need to log into Keybase from within Termux so you can add Termux as a device in Keybase. Just run the login command:

$ keybase login

... and follow the on-screen prompts.

Installing the Script

Now we're ready to install the script. When you share a file to Termux, it will look in a specific folder for a script with a specific name, and use that script if it exists. For this reason, we first need to create that folder, and go into it:

$ mkdir ~/bin
$ cd ~/bin

Now that we're in the folder where we want the script to be, we need to download the script and make it executable:

$ curl -O
$ chmod +x termux-file-editor

That's it! You now have the ability to share files from your Android device directly to your KBFS!

Using the Script

Now that we have the script installed, we just need to share a file from any file explorer. I use Solid Explorer, but you should be able to use any file explorer, including whatever comes stock with your phone.

In any file explorer you use, you'll likely just need to navigate to the file you're sending, and long press on it, then choose 'share' from the menu. After choosing 'share' you'll be presented with a list of different apps you can share to. Find Termux in this list and select it. Now you should be presented with a dialog from Termux asking where you want to save the file to. At this point, you'll want to tap the 'edit' button on the bottom right of the dialog in order to send the file to the KBFS script. When you do this, you will see a Termux window come up and run the script. There are a few things to note about running the script itself:

  1. Even though you logged into Keybase, you will eventually get logged out. This happens fairly frequently. The difference, though, is that now you only need to provide your Keybase password, as keybase already has your username saved, and Termux has already been added to your account as a device. The KBFS script will check if you're logged in, and if you're not, it will prompt you for your password in order to log you in.
  2. The script will ask you where you want to save the file, and will give you 3 options:
  3. After the file has been saved, you can find it in the location you specified (private, public, or shared) in a folder named termux-files.
  4. As of right now, the script will not overwrite an existing file. If a file with the same name already exists in the termux-files folder, the script will fail. I may change this in the future to have the script prompt you to ask if the file should be overwritten.

Keybase in Docker

This is a set of scripts I've been working on to run keybase bots in docker containers. This short writeup will mostly tell you how to use my scripts to build your own image, and I assume that you already have docker installed and configured on your own system. I'd also like to point out that this is a hobby project, and I likely did some stuff that you wouldn't see or want to see in a production environment. Feel free to contact me on Keybase if you can suggest any improvements.

Folder Structure

|-- Dockerfile
`-- keybase


This is the Dockerfile that holds the instructions for building our image

This is a bash script which will do the following:


All files in this folder will be copied into /home/keybase when the image is built. This is where you should put any scripts you'll be running from

How to use


Link: kbdocker.tar.gz
Size: 1.8K
SHA1: 6441d6aaf0db412146e36b558c745b1f80032b77

Contact info

I've created a small site with keybase pages to share my personal contact info with certain keybase contacts. If you're on that list, you can run the following command from a bash terminal to grab my signed contact info. Your bash shell must have keybase, curl and jq installed for this to work. If you'd like to be added to the list, you can contact me on keybase.

user=$(keybase config get current_user | tr -d '"'); \
password=$(curl | jq -r ".$user" | keybase decrypt); \
curl -u $user:$password

Upload image

I wrote a small script to upload an image from a URL to a team chat. This is mostly just a proof of concept. This script is to be run in a bash terminal. Your bash shell must have keybase and curl installed.


./ <team> <channel> <url>


./ keybasefriends random


Size: 884B
SHA1: addf980612bddf643bbefd0a55d78ad5a409b521

This file was last updated on 2018-11-16 at 14:30:19 Eastern