How To Setup an XMPP Server For Private Messaging
Private messaging applications have been discussed a lot lately. It has a much more intimate feeling as we use it to directly communicate with our closest friends and family. Most of the current private messaging solutions don't have your privacy and security in mind so in this article I'll discuss how you can set up an XMPP server so you can maintain full control over your communications.
The Problem With Private Messaging
When WhatsApp announced that they'll be sharing more userdata with their parent company Facebook, a lot of people started searching for better solutions. It was no secret that WhatsApp already monitored the metadata of your messages which can give them a fairly deep insight into your behaviour especially when paired with your Facebook identity. However, alternatives such as Telegram and Signal also have some issue that people have spoken about in the past. Telegram doesn't even use end to end encryption by default and the choice of using an encryption algorithm that they created themselves is strange when there already exists tried and true methods for maintaining user security. Signal doesn't allow users to host their own instance so you're inevitably reliant on them as a service. Other alternatives such as Matrix allow for federation, where users can host their own server that communicates with a wider network of self-hosted servers. The founder of Signal rejected the idea of using the Matrix protocol over supposed security concerns.
What is XMPP
XMPP is a protocol that's been around for a while. The first notable feature is that it's federated like Matrix. This means that individuals can set up their own servers and each server can communicate with other public instances. It's completely open source and allows for end-to-end encryption so you can feel safe knowing that your messages aren't being decrypted on some companys backend like WhatsApp or Telegram. The ability to host your own server gives you so much control and the ability to customize it as much, or as little as possible.
The server I'll be discussing today is Prosody. It's very minimal so it won't take up much space and you'll be able to get it set up in under 10 minutes. For all of the steps you can check out my video for further explanation.
So the first thing you'll need is a domain name and a server. Once you know that your domain is pointing to your servers IP address you can install the Prosody package. I'm on Ubuntu so I'll be using APT but check the documentation for whatever OS your server is running. If you're on Ubuntu like me simply run the below instruction.
sudo apt-get install prosody
Next you'll need an SSL certificate for your domain. If you have https already then you can skip this. SImply install letsencrypt and run the command to set it up.
sudo apt-get install letsencrypt sudo letsencrypt -d <Your Domain Name>
Next you'll need to add both the keychain and the private key to a single file. Then the prosody CLI will be able to handle it. To do this simply run the below command.
sudo sh -c ' cat /etc/letsencrypt/live/shiteposting.com-0002/privkey.pem /etc/letsencrypt/live/shiteposting.com-0002/fullchain.pem > key-and-cert.pem' sudo prosodyctl --root cert import key-and-cert.pem
That's the bulk of your setup done. The only other thing to do is to edit a line in the config file and add your users. The config file is at the location /etc/prosody/prosody.cfg.lua and you'll need to change VirtualHost "example.org" to your domain.
Then you can finally add your user using the CLI command. The format is you need to specify your username@yourdomain .
sudo prosodyctl adduser email@example.com
There you have it. In just a few commands you'll have your very own private chat server and you'll be able to re-use the domain for your website. To connect simply download an XMPP client for your phone or computer. If your on Android you can use the app "Conversations" and if you're on IOS you can use "Monal".
Stay happy and stay private.