Setting up SSB-Pub Server

and migrate your profile

Published July 9, 2020 #howto, #scuttlebutt, #p2p

I wanted to move my ssb installation over to a new computer, and the easiest way was to setup a pub server, invite the old and the new computer to the pub, and then swap out the keys. Here's how to do it.

Overview

  1. Create a server & name

  2. Install docker

  3. Create the docker image

  4. Setup directories, config, and easy shell commands

  5. Start up a container

  6. Publish yourself as a pub

  7. Connect your client

Create a server

I'm using debian 10 on digital ocean, but I'll let you get the system on the internet. The only key thing is that it needs to have port 8008 accessible from the outside world.

Install docker

I prefer to have things contained in a Docker container compared to polluting my environment. This just keeps things cleaner in the future so you don't have node or whatever floating around on your system. This may be overly complicated if you aren't already a docker user, or if you already have node installed on your system.

If you already have node, you can follow the setting up a pub directions straight from the mothership.

apt update
apt-get install -y \
	 apt-transport-https \
	 ca-certificates \
	 curl \
	 gnupg2 \
	 software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -

add-apt-repository \
	 "deb [arch=amd64] https://download.docker.com/linux/debian \
     $(lsb_release -cs) \
     stable"
apt-get update
apt-get install -y docker-ce

Write your Dockerfile

On the server, create a directory to work in, like ~/ssb

mkdir -p ~/ssb
cd ~/ssb

And then create a Dockerfile:

FROM node:10

RUN npm install -g ssb-server

EXPOSE 8008

HEALTHCHECK --interval=30s --timeout=30s --start-period=10s --retries=10 \
  CMD ssb-server whoami || exit 1
ENV HEALING_ACTION RESTART

ENTRYPOINT [ "/usr/local/bin/ssb-server" ]
CMD [ "start" ]

And then build this with

docker build . -t ssb-server

The reason that we are doing this in a seperate directory is to make sure that we don't send the whole pub data instance to docker build if we want to do this in the future.

You could also do this on your local machine and the publish the image to dockerhub, but this is really just to isolate the npm install not to make something publically available.

Setup directories and config files

mkdir ~/pubdata

Create basic ~/pubdata/config, make sure to add your DNS name or ip address in the external field.

{
  "connections": {
    "incoming": {
      "net": [
        { "scope": "public", 
          "host": "0.0.0.0", 
          "external": ["Your Host Name or Public IP"], 
          "transform": "shs", 
          "port": 8008 
        }
      ]
    },
    "outgoing": {
      "net": [{ "transform": "shs" }]
    }
  }
}

And create a ~/ssb-server script that will let you interact with the container that we will create in the next section:

#!/bin/sh

docker exec -it ssb-server ssb-server "$@"

Also be sure to chmod +x ssb-server to make it runnable.

Create the container

docker run -d --init --name ssb-server \
   -v ~/pubdata/:/root/.ssb/ \
   -p 8008:8008 \
   --restart unless-stopped \
   ssb-server
-dDetach and run as a daemon
–initUse tini to handle signals
–nameName of the container, which is the same as the instance
-vMap ~/pubdata to the ~/.ssb dir inside the container
-pExpose 8008 to the internet
–restartFor reboots, etc

Now check the logs to make sure that everything started up correctly.

docker logs ssb-server

If that looks good We can now test this by running command ./ssb-server whoami command to see if it's responding correctly.

If it's working, then publish an about entry for your pub. This is what I did:

./ssb-server publish --type about \
   --about  "@stufffromthewhoamicommand" \
   --name "pub.willschenk.com" \
   --description "Call me"

Create an invite

Once this is working, it's time to create some invites so you can connect your local instance to this pub.

./ssb-server invite.create 3

That will spit out an awesome looking string. We'll use that in our clients to connect.

Migrate your stuff over

On the new machine download patchwork which I found to be more stable than patchbay. I had better luck building from npm than using AppImage, so

npm install --global electron electron-builder node-gyp-build ssb-patchwork

You could also try oasis, which doesn't run in electron and so therefor is better, even if it is a but more minimalist.

npm -g install fraction/oasis

Note that while they both share the same .ssb data folder, if you want to use both you'll need to start up patchwork first.

  1. On the old machine, invite yourself to the pub.

  2. Sync your stuff to the new pub.

  3. On the new machine, invite yourself to the pub.

  4. Follow your old user.

  5. Wait for things to sync

  6. On the new machine, close everything.

  7. Copy the old .ssb/secret from the old to the new machine.

  8. On the new machine, delete everthing in ./ssb/flume except .ssb/flume/log.offset

  9. Open up ssb-first-aid-kit and delete the index

  10. Restart patchwork and watch that sucker index everything in the whole world.

This really started to heat my machine up!

I found that the initial index worked in patchwork, and then it started pulling in more data and eventually exploded. I was able to run oasis instead, which seemed to be better at rebuilding the index.

Now I have my old profile on my new machine.

References

Read next

See also

Using Syncthing

who needs servers

Syncthing is a way to keep things up-to-date across machines without going through any 3rd party servers. You get both backup and file synchronization without pesky servers just using the computer capacity you probably already have laying around. Lets give it a spin. Installation on Debian On the Getting Started page of syncthing they recommend using a GUI package, but we're going to install on debian on the command line.

Read more

Upgrading emacs on debian

fixing crashes

Been playing with elfeed on Emacs 26.1 on buster and it keeps crashing. I think for font related reasons. So lets follow the Emacs Wiki Instructions to upgrade to emacs-snapshots and see if that helps. Add the snap shot repository. Make sure you have the tools installed so that apt can do it's internet thing. sudo apt-get install software-properties-common sudo apt-get update Add the signing key: wget -q http://emacs.

Read more

Simple CORS workaround for local development

I've been doing a lot of web development old school, just editing HTML and JavaScript by hand without a build environment. Running npx live-server is an easy one liner to spin up a server, that opens a browser for you and also updates changes on safe. Sometimes that's not enough. Often you want to pull in data from an API, and that requires HTTPS, and also you need to work around CORS limitations.

Read more