1638 views
# Keybase CLI on Android Sometimes, you want more functionality out of your phone than what your apps offer you. If you're like me, you compile the [Keybase](https://keybase.io/) CLI from source in [Termux](https://termux.com/) because you can't use [encrypted git](https://keybase.io/blog/encrypted-git-for-everyone) on your phone otherwise. And now I can do whatever the Keybase CLI client can do! (Except anything involving KBFS. Termux doesn't have a FUSE package, yet.) This is actually surprisingly simple. I don't know anything about Go, but I just ran the commands they told me to and it worked. I hardly even had to modify the Keybase source! Shocking! ## Building the Keybase core 1. Install Termux. 2. Get some uhhhhhhhhhh dependencies (I'm not sure what exactly is required here) a. What you definitely need is the Go tools, so grab that: + `pkg install golang` 3. Create your "Go path". You'll want to add the GOPATH/PATH lines to your `.bashrc`, because that's where the Keybase binary will hide, like some kind of nerdy Python script. + ``` mkdir ~/gopath export GOPATH="$HOME/gopath" export PATH="$PATH:$GOPATH/bin" ``` 4. Clone and build Keybase. Go does this all in one command, stuffing everything in the \~gopath\~: + `go get -tags production github.com/keybase/client/go/keybase` + You'll probably have to sit for a bit while your phone runs a compiler because you told it to for some reason. + At this point, the Keybase CLI should be functioning! If you run `keybase`, you should get a big ol' screenful of command help. 5. Start `keybase service` in a new Termux session, then `keybase login` from your existing window. (For bonus points, write a shell script to start `keybase service` and use [Termux:Boot](https://wiki.termux.com/wiki/Termux:Boot) to start it automatically!) Congratulations, you now have a mostly-functional Keybase CLI in your Termux environment! ## Building `git-remote-keybase` This part is only slightly trickier! In order to use Keybase's git repositories, we need to build the "remote handler" separately. git will then invoke it automatically when given a `keybase://` protocol specifier. 1. Clone `git-remote-keybase` and its dependencies. We'll use the all-in-one command again, except use the `-d` switch to tell it to not be all-in-one and avoid building: + `go get -d github.com/keybase/kbfs/kbfsgit/git-remote-keybase` 2. `cd ~/gopath/src/github.com/keybase/kbfs/stderrutils` + This directory contains code to duplicate stderr to a file instead of redirecting it. Unfortunately for us, they disabled it on Android, which causes `git-remote-keybase` to fail pointlessly. Fortunately for us, the \*nix code works just fine on Android, so we're going to undo what they did! 3. `rm dup_stderr_dummy.go` 4. `$EDITOR dup_stderr_nix.go` (`nano`, `vim`, whatever) a. Find line 4 (starting with `// +build`) b. Change `linux,!android` to `linux android` c. Save and quit 5. Compile time! + `go install -tags production github.com/keybase/kbfs/kbfsgit/git-remote-keybase` 6. Clone your Keybase repository of choice as usual, and watch the fireworks! Don't be fooled by `git-remote-keybase` residing in the `kbfs` repo! It actually appears to have no dependency on FUSE, so unlike `kbfs` itself, you are free to use Keybase encrypted git repos on Android with impunity. :3 Hit me up [@Skirmisher@mastodon.social](https://mastodon.social/@Skirmisher) if you need clarifications, have suggestions, or just want to say "what the fuck". *And if you want more, ask me about my Android `pass` setup!*