I put this here mostly because I forget how to do it and have to make multiple starts to get it right.
chroot SFTP accounts
I had to create user accounts for customers
and give them access to
files to/from secured areas of our server.
We wanted to use
functionality to ensure
that no customer could see other customers' data,
and prevent them from poking around
potentially sensitive areas of the server.
After a bit of trial-and-error,
I've listed the lessons-learned here
in a cook-book fashion
so that in case I ever have to do it again,
I have the steps documented.
This post was spurred to exist thanks to this Reddit post asking about creating an encrypted FTP server on OpenBSD so my reply there became the basis for this post.
Sometimes you want to turn some text
into "sarcastic Spongebob" text
so this little fragment of
will make that transformation for you:
I wanted to do some full-justification of text.
So a little
I could set the desired width
and pipe to justify it.
Most Linux, BSD, MacOS machines
so a little
and other shell utilities
can find some interesting words.
Our daughter wanted to
stopping at random intervals,
at which the dancing kids freeze in place
until the music resumes).
So what is a geek dad to do?
Load up a playlist of kids' music in
start playing the music,
and let the shell randomly freeze and resume the music
This does as
for some random interval between
seconds, then does as
seconds before unpausing the music.
You could do something similar with
if you prefer them.
Over on Twitter
I was having a discussion about creating a
to protect yourself from accidentally rebooting the wrong machine
by requiring you to type the hostname
of the machine you wanted to reboot.
If you need such,
you can add these functions to your
to create such a
The function shown on Twitter had the logic reversed
so make sure you get the "=" and "!=" correct.
you want to proceed with the shutdown;
if they are
you want a warning.
If you run on OpenBSD
you can specify
While I'm not sure when others would use this I wanted to find the Nth word of a text file so I used this to find the, say, 318th word of the document:
Yes, it can get tripped up by non-Latin characters, hyphenated words, or other edge-cases, but for my 7-bit ASCII input text, it did the job.
Occasionally I have multiple windows open in
and want to add all of those files to
Rather than specifying each filename explicitly,
I use this:
Occasionally I want to
one or more files in
and, if everything looks good,
then add them.
To do so,
I often take advantage of
notation to do a replacement:
The second command replaces
turning the command into
git add -- file1.txt file2.txt
without having to retype the entire command.