The blog.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

108 lines
4.3 KiB

  1. ---
  2. title: Using Signal on a server
  3. description: >
  4. A guide to setting up signal on a machine to run automatic notifications.
  5. created: !!timestamp '2019-04-08'
  6. time: 1:54 PM
  7. tags:
  8. - signal
  9. - security
  10. ---
  11. For a long while, I'd been using an email to SMS gateway to push
  12. important notifications from my server, such as SMART error messages,
  13. to my phone. After all the
  14. [NSA warrantless surveillance](https://en.wikipedia.org/wiki/NSA_warrantless_surveillance_(2001%E2%80%932007)),
  15. I made a commitment to encrypt as much of my communications as possible.
  16. When Signal came out, I adopted it because of it's strong encryption and
  17. privacy. Ever since I've been wanting to use it for notifications from
  18. my server. I finally got around to trying out the CLI version, and got
  19. it to work.
  20. The installation of the command line utility for Signal was more straight
  21. forward than I was expecting. I decided to use
  22. [signal-cli](https://github.com/AsamK/signal-cli) and I was a bit worried,
  23. as it uses Java. Java has historically been difficult to run on FreeBSD
  24. due to lack of support and draconian licensing terms. I was surprised
  25. that the packages for OpenJDK 8 were both present and just worked on my
  26. server. A simple `pkg install openjdk8` got Java up and running.
  27. One thing to note is that the package said that fdesc and proc needed to
  28. be mounted for Java to work, but I did not, and things still worked.
  29. There are likely other parts of Java that may not work w/o those mounted,
  30. but not for Signal.
  31. As I have been using OSS for a long time, I like to build things from
  32. source, so I followed the instructions at
  33. [Building signal-cli](https://github.com/AsamK/signal-cli#building) and
  34. got the command built with out any trouble.
  35. Once the command was built, the
  36. [Usage guide](https://github.com/AsamK/signal-cli#usage) provided the
  37. basics, but didn't include instructions on how to verify the safety
  38. numbers to ensure that the initial exchange was not MitM'd. There is a
  39. [man page](https://github.com/AsamK/signal-cli/blob/master/man/signal-cli.1.adoc),
  40. but it requires a2x and separate steps to build, but a little bit of
  41. digging got me the necessary steps (also, it turns out that the adoc
  42. format is a simple text format).
  43. With a bit of searching, I found the `listIdentities` and `verify`
  44. commands. There may have been another way, but because I had sent a
  45. test message, my phone was listed:
  46. ```
  47. $ signal-cli -u +XXXXXXXXXXX listIdentities
  48. +YYYYYYYYYYY: TRUSTED_UNVERIFIED Added: Sat Apr 06 18:43:15 PDT 2019 Fingerprint: ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ Safety Number: WWWWW WWWWW WWWWW WWWWW WWWWW WWWWW WWWWW WWWWW WWWWW WWWWW WWWWW WWWWW
  49. ```
  50. And then I needed to use the `trust` subcommand:
  51. ```
  52. $ signal-cli -u +XXXXXXXXXXX trust -v 'WWWWW WWWWW WWWWW WWWWW WWWWW WWWWW WWWWW WWWWW WWWWW WWWWW WWWWW WWWWW' +YYYYYYYYYYY
  53. ```
  54. The hardest part of this was figuring out how to invoke the command upon
  55. reception of an email. I used an alias listed in `/etc/aliases` to forward
  56. the email to both the SMS gateway and myself. The issue with trying to
  57. invoke the command from here was that the command was run as the `mailnull`
  58. user, which of course didn't have access to my user's home directory to
  59. read the private key. After a bit of debating, I remembered I use
  60. `procmail`, and realized this was the best way to send the message.
  61. I created a symlink for the command into my user's bin directory, created
  62. a short script called `sendcell`:
  63. ```
  64. $ cat ~/bin/sendcell
  65. #!/bin/sh -
  66. ~user/bin/signal-cli -u +XXXXXXXXXXX send +YYYYYYYYYYY
  67. ```
  68. and then added a filter to my `.procmailrc` file. The filter at first
  69. looked like this:
  70. ```
  71. :0Wf
  72. * ^TO_celluser@([^@\.]*\.)*example.com
  73. | sendcell
  74. ```
  75. But after the first test, it included all the headers, including all the
  76. `Received` headers, so I updated it to use `formail` to remove all but the
  77. `From`, `Subject` and `Date` (in case the message gets significantly delayed,
  78. I can see by how much) headers:
  79. ```
  80. :0c
  81. * ^TO_celluser@([^@\.]*\.)*example.com
  82. {
  83. :0Wf
  84. | formail -k -X From: -X Subject: -X Date:
  85. :0
  86. | sendcell
  87. }
  88. ```
  89. and now I get the messages delivered to my phone securely!
  90. It is tempting to use this to be able to invoke commands on my server
  91. remotely, but there isn't much I need to do when I don't have my laptop
  92. with me.