LibreTerminal
The app that lets a script on your own computer ask you for a password, a yes or no, or a short code, and opens a terminal on your computers from your phone. What it is, how to set it up and use it.
On this page
LibreTerminal lets you answer your computers from your phone.
Say a script on your computer needs a password to carry on, or wants to know "Deploy to production? yes or no". Instead of waiting at the keyboard, the script asks you. Your phone shows a notification, you tap it, and you answer. The answer goes straight to the waiting script and is never saved.
It also has a terminal for your own computers and servers, with saved commands (like tmux attach -t unlock) that you can put on your phone's home screen.
A Preview
LibreTerminal is new and version 0.x, so expect the odd rough edge. It is for Android 8 or newer. Download it from libreportal.org/download.
What it does#
- Answers for your scripts. A script asks for a password, a yes or no, or a short code. You get a notification and answer in the app.
- A terminal on your own computers and servers. Use the extra keys row for Tab, Ctrl, Esc and the arrows, and pinch to zoom the text.
- Run this? A script can ask you to run one command, and you see it in full first.
- Saved commands. Keep the commands you run often, and put any of them on the home screen as a shortcut.
- The LibrePortal look. It has the same themes and backgrounds as the other LibrePortal apps.
Set it up#
- Install LibreTerminal from libreportal.org/download. The first time, Android asks you to allow installs from your browser.
- Add a computer. Give it a name, its address and the user you sign in as. See Add a computer.
- Let the computer know your phone. Tap Sign in with the password, once. See Let the computer know the phone.
- Turn on requests. Tap Let (computer) ask me things. This also turns on listening. See Set up requests. That is all: turning on requests also makes LibreTerminal listen for them. You don't need another app. See Get the notification.
Add a computer#
Tap Add a computer and fill in:
- Name: what you want to call it, for example "home-pc".
- Address: its name or number on your network, or its internet address.
- User name on it: the account you sign in as on that computer.
The first time you connect, LibreTerminal asks First time connecting to (computer). Check it is your computer, then tap Connect. Show details has its fingerprint, if you want to compare it. After that it checks the identity every time (see A changed identity warning).
Advanced Compare the fingerprint
On the computer, run ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub. The SHA256: part it prints should be the same as under Show details.
New to the command line? How to run LibrePortal commands →
Let the computer know the phone#
Your phone has its own key, which stays on the phone. A computer has to learn that key before it lets the phone in. There are two ways:
- Sign in once with the computer's password. Tap Sign in with the password. LibreTerminal signs in with it one time and hands the computer the phone's key. The password is not kept. Once the phone's key works, this card goes away.
- Add the key yourself. Tap Set up by hand (or Advanced at the bottom of the computer's page). It shows the phone's key, with Copy the key and Share. Add it to the computer's list of keys.
Advanced Technical detail
The phone's key is created on the phone and sealed by the Android Keystore, so it cannot be copied off. The computer keeps the public half in ~/.ssh/authorized_keys.
New to the command line? How to run LibrePortal commands →
Set up requests#
Open the computer in the app and tap Let (computer) ask me things. This puts a small helper on the computer, so scripts there can ask you things, and sets up its notifications too. If a step fails, the app says which one, with Try again. Then it asks you to let LibreTerminal send notifications and run in the background: allow both, or requests cannot reach you while the app is closed. LibreTerminal then listens for the computer by itself. When it is done the card shows Requests are on and Listening, with Check now, See what's waiting and Turn off.
If you see Requests aren't set up on (computer) yet, tap Set up requests. It checks that the computer really accepts the phone before it says done.
Advanced What it installs
It installs small scripts in ~/.local/bin: lt-ask (and lt-run and lt-link), which a script calls to ask, and lt-answer, which is the only thing the phone's request key is allowed to run. That key is limited in authorized_keys so it has no shell and no forwarding. To set it up by hand instead, open Advanced on the computer's page: Requests, by hand has the line for authorized_keys, and the scripts are in the tools/ folder of the source code (bash lt-install.sh). Tap I've done it after. Set up again puts the newest helper on the computer.
New to the command line? How to run LibrePortal commands →
A script asks like this:
pw=$(lt-ask --secret "Signing key password") || exit 1
if lt-ask --yesno "Deploy to production?"; then echo deploying; fi
code=$(lt-ask --code --timeout 120 "Code from your email")
--secret asks for a password (the default), --yesno asks a yes or no and --code asks for a short code. --timeout SECONDS sets how long it waits (the default is 5 minutes).
Get the notification#
LibreTerminal listens for your computer's requests itself. There is no other app to install, and no Google services are used. While it listens, it shows a small notice, "Listening for home-pc". A request shows as LibreTerminal's own notification, and tapping it opens the question.
Under the computer's Requests card:
- Listening means it is connected and will hear a request at once.
- Check now looks again straight away, if you think one was missed. The notice has the same button.
- It reconnects by itself if the network drops, and starts again after the phone restarts. It stops when no computer has requests on.
If you would rather use the ntfy app, Advanced on the computer's page has Use the ntfy app instead.
Advanced Your own ntfy server, and technical detail
Notifications travel through an ntfy server: the one the computer posts to (ntfy.sh unless you change ntfy server for new set-ups under Advanced before turning on requests, for example to your own https://ntfy.example.org). LibreTerminal reads the computer's topic over ntfy's JSON stream, in a foreground service. Nothing changes on the computer: lt-ask keeps posting to ntfy.
The topic is a long random name that starts with lp-lt- and the computer's name (some servers only let anyone use topics with a given start; change Topic start for new set-ups under Advanced for other servers), and the address is saved on the computer as a line ntfy_url=… in ~/.config/libreterminal/ask.conf; Advanced shows it. The notification carries only the question and the request's number, never an answer. The file holds plain key=value lines and is read as text, never run.
If your ntfy server asks you to sign in to read, the card says The notification server wants a sign-in. Paste an access token that can read those topics into Access token under Advanced (it is kept sealed on the phone). Plain http:// is only used for an address on your own network or VPN; anywhere else it must be https://.
Android may put a background app to sleep. While notifications or background running are not allowed, LibreTerminal says so on its home page and on the computer's page, with a button for each. It also looks again about every ten minutes in case the phone slept through a message. A Force stop in Android's settings stops listening until you open the app again.
New to the command line? How to run LibrePortal commands →
Accept requests by themselves#
Some questions you always answer yes. Accept requests by themselves has one switch in Settings for all your computers, and each computer can be set to Default, On or Off, there or on its page. Its yes/no questions are then answered Yes by the phone, with a quiet notice "Accepted: (question) from home-pc". The computer's page keeps a short list under Accepted by itself. It needs LibreTerminal to be listening for that computer.
It is off unless you turn it on, asks you once when you do, and never answers a password, a code or anything you'd type. Commands to run and servers to link still ask too. A script can also refuse it for a dangerous question:
lt-ask --yesno --always-ask "Erase the disk?" # always asks you
lt-ask --yesno --auto-file /tmp/auto "Restart now?" # writes "auto" to the file if the phone answered by itself
Advanced Technical detail
The phone asks lt-answer auto <id>, which only accepts a yes/no question that was not marked --always-ask. It writes yes to the waiting lt-ask, which says on its error output that the answer was automatic. Computers set up before 0.1.3 need Set up again (under Advanced) to get this; until then every question is simply asked as before.
New to the command line? How to run LibrePortal commands →
Run a command only when you say so#
Sometimes a script needs you to run a command it is not allowed to run itself. It can ask you on your phone instead:
lt-run "Free up disk" -- docker system prune -f
lt-run --always-ask "Reboot" -- sudo reboot
Your phone shows Run this? with the reason, the exact command in full (nothing is hidden, odd characters are spelled out), the computer it runs on and the folder. Tap Run to run it, or Don't run. Nothing runs before you tap. After Run, the phone shows the exit code and the last lines of output, and the script gets them too.
The computer's page keeps a short Commands list: what was asked, when, and how it ended.
It only runs what was queued
The phone never sends a command. It says "run request 7" and the computer runs only the command that script queued. If that command is changed after you were shown it, it is refused and nothing runs.
Advanced Run approved commands automatically
Under Advanced on a computer there is a switch, Run approved commands automatically. It is off. Turning it on asks you first ("Commands from home-pc will run without asking you"). When it is on, a run request runs at once and the phone shows a notice with the exit code; everything is in the Commands list. A command queued with --always-ask still asks you. Turning it off takes effect straight away.
New to the command line? How to run LibrePortal commands →
Advanced Technical detail
lt-run queues the command as a list of arguments (a shell string only with --shell) with its folder and PATH, in a private folder (~/.libreterminal/requests, mode 700). The phone's key can only run lt-answer, which runs a queued command only when the request number and the command's sha256 fingerprint both match, once, from the queued folder, with a time limit (--run-timeout, default 10 minutes). Exit codes of lt-run: the command's own, 3 for Don't run, 124 for no answer in time (--timeout, default 30 minutes) or a command that ran out of time. Computers set up before 0.1.4 need Set up again under Advanced.
New to the command line? How to run LibrePortal commands →
Link servers to LibrePortal in one tap#
A computer that can already ask you things can also hand your phone invites from LibreAccess, to link plain Linux servers to the LibrePortal app.
- You get a notification: Link 3 servers to LibrePortal? Tap it.
- Each server has a row with its name, address and a tick box. A server your LibrePortal app doesn't have yet is marked New and starts unticked: tick the ones you want.
- Tap Yes. The LibrePortal app opens and links them, one after another. Tap No to link nothing.
Each invite works once and runs out after 10 minutes. It is never in the notification, and the unticked ones are thrown away. You need LibreTerminal 0.1.7 and LibrePortal app 0.41.62 or newer, with LibreVault unlocked (the app waits for it if not).
On the computer, a script writes a file only you can read (mode 600): the first line LTLINK1, then one line per server with the name, the address and the LA1- code from libreaccess invite, separated by tabs. A fourth field new marks a server never linked before. Then:
lt-link invites.txt
lt-link deletes the file once it has queued it, and prints sent or skipped for each server. Exit codes: 0 something was sent, 3 you said No, 124 no answer in time, 2 a bad file. A computer set up before 0.1.7 needs Set up again under Advanced.
Answering#
- A script on the computer asks. Your phone shows LibreTerminal's notification with the question.
- Tap it. LibreTerminal opens the request. Type your answer, or tap yes or no.
- The answer goes straight to the waiting script over SSH. It is not saved on the phone or the computer.
If nobody answers in time, the script is told so and the request is removed. You can also open the computer in the app to see its waiting requests.
Advanced Technical detail
The answer travels through a named pipe held open by the waiting lt-ask. It is never written to a file or a log and never appears in a command line.
New to the command line? How to run LibrePortal commands →
The terminal#
Tap Open terminal on a computer's card to get a terminal on it.
- Extra keys: a row above the keyboard has Tab, Ctrl, Esc, the arrows and other keys a phone keyboard lacks.
- Pinch to zoom: pinch to make the text bigger or smaller.
- Saved commands: save a command with a name, for example
tmux attach -t unlock, and run it with Run. - Home-screen shortcuts: tap ⋯ next to a saved command, then Add to the home screen. Tapping it opens the terminal on that computer and runs the command. Copy its link is there too.
- When it can't connect, the terminal says why in one line, with Try again. Tap the (i) for what to check.
Links can open a saved command too:
libreterminal://open?host=<name>&cmd=<saved command>
For example libreterminal://open?host=home-pc&cmd=unlock, where home-pc is the computer's name in the app and unlock is the name of a saved command.
A changed identity warning#
The first time you connect, LibreTerminal remembers the computer's identity (its host key). Every later time it checks the identity is the same.
If the identity has changed, LibreTerminal refuses to connect and shows a red warning: "(computer)'s identity has changed. Not connected." That can be harmless, for example if the computer was reinstalled. It can also mean something is pretending to be your computer. Do not carry on unless you know why it changed. See troubleshooting.
Updates#
From 0.1.5 LibreTerminal tells you when a newer version is out, like the other LibrePortal phone apps.
- The notice: a green Update ready strip at the top of the home screen. Tap Update. The x hides that version.
- It keeps downloading if you go to another page, another app, or lock the phone. If it finishes while you are away, the strip says it is downloaded, with Install.
- Checked before installing: the file must match the checksum libreportal.org gives and be signed with the same key as the app you have. Otherwise it is refused and nothing is installed.
- Android asks once to allow installs from LibreTerminal. Allow it, then tap Update again.
- How often: when you open the app, at most every four hours. Settings → Updates → Check for updates asks right away.
- What is sent: only the request for
libreportal.org/download/libreterminal.json. Nothing about you or your computers.
To update by hand instead, install the new package from libreportal.org/download.
Privacy#
- Keys stay on the phone, sealed by the Android Keystore.
- Answers are never saved, on the phone or the computer.
- No analytics, and no network except the SSH connections you start, the listening for requests on your own notification server, and one small look at libreportal.org to see whether a newer version is out (see Updates).
- Open source under the AGPL-3.0-or-later. It is built on sshj and Termux's terminal view, both Apache-2.0.