Smallweb 0.20

by Achille Lacoin

3 min read

Hey! I had a hard time getting back to work after the holidays, but I'm finally back with a new release of Smallweb!

This week, I've added one of my favourite feature ever: SSH support. This is a really unique feature that I haven't seen in any other platform, and I'm super proud of it!

SSH Support

A new --ssh-addr flag was added to the smallweb up command:

smallweb up --ssh-addr :2222

It allows you to access both the smallweb and the apps clis through SSH. To access the smallweb cli, you can use the _ user:

ssh -t -p 2222 _@<ipv4> help
Host websites from your internet folder

Usage:
  smallweb [flags]
  smallweb [command]

Available Commands:
  changelog   Show the changelog
  completion  Generate the autocompletion script for the specified shell
  config      Get a configuration value
  crons       List cron jobs
  doctor      Check the system for potential problems
  fetch       Fetch a path from an app
  help        Help about any command
  init        Initialize a new workspace
  link        Create symbolic links
  list        List all smallweb apps
  logs        View app logs
  open        Open an app in the browser
  run         Run an app cli
  secrets     Manage app secrets
  service     Manage smallweb service
  sync        Sync the smallweb config with the filesystem
  up          Start the smallweb evaluation server
  upgrade     Upgrade to the latest version

Flags:
      --dir string   The root directory for smallweb
  -h, --help         help for smallweb
  -v, --version      version for smallweb

Use "smallweb [command] --help" for more information about a command.

And to access an app cli, you just use the app name as the user:

ssh -t -p 2222 smallblog@<ipv4> help
Usage: smallblog [options] [command]

Smallblog CLI, handle your articles from the terminal.

Options:
  -V, --version              output the version number
  -h, --help                 display help for command

Commands:
  create|c [options] <name>  Create a new blog post as draft
  publish|p <name>           Publish a draft post
  list|ls [options]          List all blog posts
  archive|a <name>           Archive a blog post as a draft
  remove|rm <name>           Remove a blog post. You can only delete a draft post. If you want to delete a published post, use `smallblog archive` first. This
                             does NOT delete the images or videos of the post, You should delete them manually.
  help [command]             display help for command

To avoid setting the -p flag every time, you can add the following to your ~/.ssh/config file:

Host smallweb.run
  User _
  Hostname <ipv4>
  Port 2222
  RequestTTY yes

And then you can just run:

# run the smallweb cli
ssh smallweb.run ls

# run the smallblog cli
ssh [email protected] ls

To connect, you'll need to add your public key to the ~/smallweb/.smallweb/authorized_keys file.

Multiple improvements to the static file server

The static file server has been improved in multiple ways:

First, if the served directory contains a 404.html or a 404.md file, it will be served when a file is not found.

There is also basic supports for _redirects files, as used by Netlify. Currently only basic redirects are supported:

/docs /docs/getting-started 301

I plan to add support for every netlify features in the future.

You can find the source of the static file server here.

Deprecate access to the cli in admin apps

In previous version of smallweb, admin apps were able to access the smallweb cli using Deno.Command. Ultimately, I don't think this was the right decision, as it could lead to security issues.

I think ssh is a better way to interact with your smallweb instance, so I've decided to deprecate access to the cli in smallweb apps.