First, install the `nncp` package on both systems. In addition to that, install the `openbsd-inetd` package on the server. (In the following passages, I'm connected as `root` to the server.)
Generate new configs on the systems that are missing `/etc/nncp.hjson`.
nncp-cfgnew > /etc/nncp.hjson chown nncp:nncp /etc/nncp.hjson chmod 660 /etc/nncp.hjson
Examine the file using a text editor. Each system needs to know the public keys of the other.
So, on the laptop, I need to add to add the public keys of the server. I also want to specify that I'm going to call the node on a regular basis and that files sent to me from that node should be saved in my "incoming" directory. I also want to accept mail.
sibirocobombus: { id: ... exchpub: ... signpub: ... noisepub: ... incoming: "/home/alex/incoming/sibirocobombus" exec: { sendmail: ["/usr/sbin/sendmail"] } addrs: { internet: "alexschroeder.ch:5400" } calls: [ { cron: "12 * * * *" } ] }
And on the server, I need to add the public keys of the laptop. I also want to save incoming files from the laptop. And I want to accept mail.
melanobombus: { id: ... exchpub: ... signpub: ... noisepub: ... incoming: "/home/alex/incoming" exec: { sendmail: ["/usr/sbin/sendmail"] } }
Note how the laptop calls the server but the server does not call the laptop!
Let's make sure those directories exist:
mkdir ~/incoming ssh sibirocobombus mkdir incoming
Let's create a file and send it from the laptop to the server using `nncp-file`:
echo Hello > hello.txt sudo -u nncp nncp-file hello.txt sibirocobombus:
Check the log using `nncp-log`:
nncp-log | tail -n 1 2024-06-28T21:36:02Z File hello.txt (282 B) is sent to sibirocobombus:hello.txt
Let's connect to the server and check:
ssh sibirocobombus ls incoming
Nothing has arrived!
Let's call the server using `nncp-call`:
sudo -u nncp nncp-call sibirocobombus 2024-06-28T22:07:36Z ERROR Calling sibirocobombus (alexschroeder.ch:5400): dial tcp [2a02:418:6a04:178:209:50:237:1]:5400: connect: connection refused
Oops. It's not running? That's right, I need to run `nncp-daemon` on the server side.
Add the following to `/etc/inetd.conf` on the server to accept NNCP connections on port 5400:
5400 stream tcp nowait nncp /usr/bin/nncp-daemon nncp-daemon -quiet -ucspi
Reload it:
systemctl reload openbsd-inetd
Try again on the laptop:
sudo -u nncp nncp-call sibirocobombus 2024-06-28T22:14:13Z We have got for sibirocobombus: 1 packets, 486 B 2024-06-28T22:14:13Z ERROR SP with sibirocobombus (nice MAX): reading: EOF 2024-06-28T22:14:13Z ERROR Connection to sibirocobombus (alexschroeder.ch:5400): EOF
Back to the server:
nncp-log 2024-06-28T22:15:25Z ERROR SP nice MAX: waiting for first message: unknown peer: ... 2024-06-28T22:15:25Z Connected to unknown
Strange! That id listed there matches my laptop's `noisepub`. Checking the `/etc/nncp.hjson` on the server again, I see that I had pasted the wrong pubkeys… 🤦 Fix that and try again…
sudo -u nncp nncp-call sibirocobombus 2024-06-28T22:19:31Z We have got for sibirocobombus: 1 packets, 486 B 2024-06-28T22:19:31Z Connection to sibirocobombus (alexschroeder.ch:5400) 2024-06-28T22:19:31Z Tx QAROTFMX25ZPQOT5..I6JKH75EC2DMSSZQ 486 B/486 B 100% (0 B/sec) 2024-06-28T22:19:31Z Packet QAROTFMX25ZPQOT5DEQQC7JE7EN3UD2FZIJNI6JKH75EC2DMSSZQ is sent 2024-06-28T22:19:42Z Finished call with sibirocobombus (0:0:11): 32 KiB received (32 KiB/sec), 33 KiB transferred (33 KiB/sec)
Looking good! Check for the file on the server:
ssh sibirocobombus ls incoming
It's not there!
Let's investigate on the server:
nncp-log 2024-06-28T22:19:31Z Packet QAROTFMX25ZPQOT5DEQQC7JE7EN3UD2FZIJNI6JKH75EC2DMSSZQ (486 B) (nice B): 0% 2024-06-28T22:19:31Z melanobombus has got for us: 1 packets, 486 B 2024-06-28T22:19:31Z Connection with melanobombus (PIPE) 2024-06-28T22:19:31Z Got packet QAROTFMX25ZPQOT5DEQQC7JE7EN3UD2FZIJNI6JKH75EC2DMSSZQ 100% (486 B / 486 B): done 2024-06-28T22:19:42Z Finished call with melanobombus (0:0:11): 33 KiB received (33 KiB/sec), 32 KiB transferred (32 KiB/sec)
This looks good, so we have the packet! And we can confirm this using `nncp-stat`:
nncp-stat melanobombus nice: B | Rx: 486 B, 1 pkts | Tx: 0 B, 0 pkts self
What needs to happen now is "tossing" using `nncp-toss`. This is, "processing" the packet and thereby delivering it.
sudo -u nncp nncp-toss 2024-06-28T22:24:28Z ERROR Tossing file melanobombus/QAROTFMX25ZPQOT5DEQQC7JE7EN3UD2FZIJNI6JKH75EC2DMSSZQ (6 B): hello.txt: mktemp: open /home/alex/incoming/nncpfile17dd4b56c39f64d4: permission denied
That's right, the incoming file should be writable by more people…
chgrp nncp /home/alex/incoming chmod g+w /home/alex/incoming
Try again!
sudo -u nncp nncp-toss 2024-06-28T22:26:35Z Rx file QAROTFMX25ZPQOT5..I6JKH75EC2DMSSZQ 6 B/6 B 100% (0 B/sec) 2024-06-28T22:26:36Z Got file hello.txt (6 B) from melanobombus
It worked:
ls -l /home/alex/incoming/ total 4 -rw-r--r-- 1 nncp nncp 6 29. Jun 00:26 hello.txt cat /home/alex/incoming/hello.txt Hello
🥳
I need to think about admin issues, clearly.
I need to set up regular `nncp-call` on the laptop; I need to set up regular `nncp-toss` on the server.
It would be nice to switch from `inetd` to `systemd` perhaps? Surely they have written a replacement for it. They have written replacements for everything! 😬
Next up, sending email back and forth!
#Administration #NNCP