howto

Setting up SSB-Pub Server

and migrate your profile

tags
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.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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

1
2
mkdir -p ~/ssb
cd ~/ssb

And then create a Dockerfile:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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

1
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

1
mkdir ~/pubdata

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
{
  "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:

1
2
3
#!/bin/sh

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

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

Create the container

1
2
3
4
5
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.

1
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:

1
2
3
4
./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.

1
./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

1
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.

1
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.

Previously

articles

Effigy, a distributed social data layer

Scuttlebutt is awesome, let’s run with it

tags
p2p
design
serverless
websockets
webrtc
effigy

Next

labnotes

Getting Websters

More glorious language

tags
emacs
howto
language