Executing Gummiworms The trials and tribulations of a grumpy curmudgeonly old git

18Jan/1311

Setting up Prosody on the Raspberry Pi for house/apartment/secret club house-wide chatroom

Screen Shot 2013-01-18 at 5.12.32 PMAlthough I only live with 4 others, wife, son & 2 cats, in a small 5 room apartment most evenings we are in different rooms, or in the summer 3 different floors, wearing headphones chilling to our own choices in music & tv. As I think it's uncouth to yell out of the window or across the apartment to get someone's attention I setup a Raspberry Pi Model B as an XMPP server running MUC. As it's only for 3 people, unless we have visitors, I chose to run Prosody, it's pretty lightweight, easy to setup, the stable version is in the raspbian repos & i've used it before. I've also used and run ejabberd, openfire, tigase, jabberd,... but IMHO they are heavier on resources and a bit harder to setup, and are overkill for my needs and anyway I like lua.

 

As stable Prosody, currently 8.2,  is in the raspbian repos you install it via apt.

sudo apt-get install prosody

which will install (if they are not already installed)

liblua5.1-0 lua-event lua-expat lua-filesystem lua-sec lua-socket prosody
 ssl-cert

Once Prosody is installed you'll need to create a config file & add some users.

First create an admin user for the server. As Prosody is running on birstall.leicestershire.lan, i'll use admin@birstall.leicestershire.lan as my admin account & create it using the prosodyctl utility.

sudo prosodyctl adduser admin@birstall.leicestershire.lan

which will ask you to enter a password for that user (twice)

Enter new password: 
Retype new password:

[As i'm going to disallow in-band registration i also created accounts for my wife & son & a non-admin account for myself after creating the admin account also using prosodyctl. But if you are going to allow users to create their own accounts you can  just skip to creating the config file.]

sudo prosodyctl adduser linda@birstall.leicestershire.lan
sudo prosodyctl adduser john@birstall.leicestershire.lan
sudo prosodyctl adduser russell@birstall.leicestershire.lan

Now you need to create a config file. It's written in lua, but you don't need to know lua to create it as it's pretty human readable.

Create a file in /etc/prosody/conf.avail with the filename of FQDN of the host Prosody is running on and a suffix of .cfg.lua using whatever editor you are comfortable with, in my case I happen to like vi/vim so i'll use that.

sudo vi /etc/prosody/conf.avail/birstall.leicestershire.lan.cfg.lua

My configuration file looks like this.

VirtualHost "birstall.leicestershire.lan" -- FQDN of host server is running on
admins = {"admin@birstall.leicestersire.lan"} -- admin account
modules_enabled = {

                "roster"; -- Allow users to have a roster. Recommended ;)
                "saslauth"; -- Authentication for clients and servers. Recommended if you want to log in.
                "tls"; -- Add support for secure TLS on c2s/s2s connections
                "disco"; -- Service discovery
                "private"; -- Private XML storage (for room bookmarks, etc.)
                "vcard"; -- Allow users to set vCards
                "legacyauth"; -- Legacy authentication. Only used by some old clients and bots.
                "version"; -- Replies to server version requests
                "uptime"; -- Report how long server has been running
                "time"; -- Let others know the time here on this server
                "ping"; -- Replies to XMPP pings with pongs
                "adhoc"; -- Support for "ad-hoc commands" that can be executed with an XMPP client
                "admin_adhoc"; -- Allows administration via an XMPP client that supports ad-hoc commands
                "announce"; -- Send announcement to all online users
                "welcome"; -- Welcome users who register accounts
                "motd"; -- Send a message to users when they log in
                "posix"; -- POSIX functionality, sends server to background, enables syslog, etc.
                 --"register"; -- Uncomment to enable mod_register
};
-- allow_registration = true -- Uncomment to llow users to register new accounts
motd_text = [[This is a private xmpp server. if you are not authorized please logoff immediately.]]
welcome_message = [[$username welcome to $host]]
disallow_s2s = true -- This is a private server so no federation
Component "conference.birstall.leicestershire.lan" "muc"
name = "MUC"
restrict_room_creation = admin -- only admin user can create a new MUC

[If you want to allow in-band registration, users can register an account from their XMPP client, uncomment the

"register"; -- Enable mod_register

&

allow_registration = true -- Allow users to register new accounts

lines.]

After you have created & saved the configuration file you need to create a symlink to it in the /etc/prosody/conf.d directory.

sudo ln -s /etc/prosody/conf.avail/birstall.leicestershire.lan.cfg.lua /etc/prosody/conf.d/birstall.leicestershire.lan.cfg.lua

[Change birstall.leicestershire.lan to your hosts name]

And then start Prosody

sudo /etc/init.d/prosody start

Actually you are restarting it as it's already running as you installed it using apt and it'll start automatically when you reboot as well. You can now login to the server, if you are the admin user create muc/chatrooms, im logged in users and do all the other things you can do using xmpp by using any xmpp compliant client such as adium, pidgin, Tkabber, psi, ...

This is just a very simple setup that works for my needs as I don't need to worry about setting up SRV records, portforwarding, federation or even much security. If you want to do a more complicated setup or just read a bit more about XMPP look at these sites.

http://prosody.im

http://xmpp.org

Share
Comments (11) Trackbacks (7)
  1. Talk about a good use of the server!

    • Hi sounds very interesting. Unfortunately I have never heard of local chatrooms & prosody. The websites quoted don’t seem to be aimed at novice users.
      How does it work in practice?
      What sort of devices can be communicated with?
      Windows PCs? smart Phones? …?

      • anything that has an im client that does xmpp/jabber will work. so pretty much any m client there is. pidgin, adium, im+ pro, trillian, …

        • Sorry but I’m none the wiser as to what happens from a user point of view.
          I’m guessing each person runs some special software on their PC, Mac, Smart Phone etc. and a message pops up when another user in the ‘chatroom’ messages them?

          • Chris, you are correct, each user runs a Instant messaging client app on you PC (e.g. on called pidgin) or a Mobile app on you Smartphone (IM+), which then connects to the Prosody server. The server then simply passes text messages, sounds, pictures between users in realtime.

          • You are partly correct…
            XMPP is an Instant Messenger Protocol.
            Have you ever used ICQ or Skype? Thats about the same system. You have a client, you can add other users and you can see if they are online.
            Clients for this software were mentioned above. There are plenty, even for smartphones.
            differences are:
            - you can add users, even if they are NOT on the same server, i.e. User Rick has an account on bla.com and you have an account on bubble.com (fictional), you can still add him. That doesnt work crosswise with ICQ cause that is another system.

            Google is still using that kind of protocol (though they migrate away from that), as does facebook (without the server to server thing though) and whatsapp (I read that they changed lots in it but basically its still XMPP.

            Anyway…I think its an excellent thing to use, since my $§%&%$/$/ ICQ account got hacked and I got pretty pissed about that. Now its gonna be quite a lot harder to do that…I got backups and I can change my password all I want ;)

    • I can’t believe how well Prosody runs on my Pi! We also only have a small handful of users but it’s proving to be fast and versatile. I found the setup learning curve quite steep (especially setting up the SRV records on ISP’s control panel). The only issue I’m having is the large variation of quality in the Jabber clients on various platforms, and this is odd considering the maturity of the XMPP protocol.

      Anyway, many thanks for your posting – very useful!

  2. I think
    “sudo ln -s /etc/prosody/birstall.leicestershire.lan.cfg.lua /etc/prosody/birstall.leicestershire.lan.cfg.lua”
    might be a typo ;-)

  3. HEllo!

    I installed it on the raspbx but when I want to connect with spark client, I get message: invalid user or password, which file do contain username and password ?
    THX Oliver


Leave a comment