💾 Archived View for josias.dev › gemlog › ssh-notes.gmi captured on 2023-04-26 at 13:08:15. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

SSH Notes

Caution: Linux jargon; some Gemini meta-discussion.

In my last reply post, I invited readers to leave a note on my Raspberry Pi.[1] I have received several notes since then, and some of you expressed interest in the idea more broadly. For those interested, I'd like to explain how it works, in case anyone wants to try for themselves.

First, thank you to everyone who has accepted that invitation so far. It's been fun to receive little notes from around the world.

We start with an user for leaving notes, I used "note", but anything works ("reply" or "comment" would also be appropriate). In this example, the user has its own home directory. We delete the password so it can be accessed without authentication.

# useradd -m note
# passwd -d note

ssh needs to be configured to open this account to the public, while restricting access to a single script.

/etc/ssh/sshd_config:

Match User note
	PasswordAuthentication yes
	PermitEmptyPasswords yes
	ForceCommand sh /home/note/write-note.sh

You can also set a ChrootDirectory for an extra layer of security. My attempts to do so a few months ago failed. I never learned to use chroot.

Update: evenfire wrote a guide on setting up SSH Notes with chroot. Use it to prevent potential attackers from accessing the filesystem.

Now the script. This handles the actual note-writing. This is the code I currently use:

#!/bin/sh

read -p 'Note: ' note
read -p 'Name (optional): ' name
read -p 'URL (optional): ' url
echo "$name: $note --- at `date` from $url">> notes
echo "Thanks for your message! I'll check it shortly. :)"

That's it! The script prompts for a note, a name, and a URL (for responding, if you so choose); then appends it to a "notes" file. Messages are read by opening /home/note/notes. You can test the script by ssh-ing to note@josias.dev.

With this model, there's no pressure for someone to write something eloquent or even contextually relevant. It's a simple way to show appreciation. Sometimes that's enough to encourage someone to keep writing.

I'm looking forward to leaving notes on your servers!

Sidenote: this concept works for other ssh-based applications, including chatrooms, Gemini browser test environments (ssh kiosk@gemini.circumlunar.space), and more. Solderpunk discussed it on his gemlog two years ago.[2] I believe the idea deserves further exploration.

~ Josias, 2022-08-18 (CC-BY-SA 4.0)

Links:

1: Counting Computers

2: solderpunk: SSH apps and accessible Gemini publishing