May 13, 2024

Antminer S9 board - Playing with linux

Once you follow the instructions for clearning the root password, the next thing to do is to stop the darn bitcoin software from running. It chatters endlessly on the console making it all but impossible to do. Here is what I did:
cd /etc/rcS.d
mv S70bmminer.sh K70bmminer.sh
mv S37bitmainer_setup.sh K37bitmainer_setup.sh
cd /usr/bin
mv bmminer bmminerXX
reboot
For some reason just renaming the start scripts didn't do it, but changing the name of the miner executable did the trick.

What do we have?

Angstrom v2013.12 - Kernel 3.14.0-xilinx-g16220c3
uname -a
Linux antMiner 3.14.0-xilinx-g16220c3 #83 SMP PREEMPT Thu Jul 12 11:42:53 CST 2018 armv7l GNU/Linux
So we are running Angstrom linux, which I hated with a passion when I had to work with it on the Beaglebone Black. It may be fine for an embedded linux, but it had many drawbacks for interactive use. So far on the Antminer, it seems fine. For example, filename completion works (it never did on the BBB). Also "vi" seems to work fine without the need to use stty on every login.

A look in /bin shows this is a busybox setup.

I see /usr/bin/perl -- so I do have a programming language (if I want to try to remember how to use perl -- and I am not sure that I do). It is certainly better than bash scripts. This is Perl 5.14.3.

network

I don't find "eth0" in any file under /etc. The network is started by /etc/rcS.d/S39network.sh and seems hardwired to use dhcp.

Let's try it. I plug in a network cable and get messages:

Sending discover...
Sending select for 192.168.0.166...
Received DHCP NAK
Sending discover...
Sending select for 192.168.0.137...
Lease of 192.168.0.137 obtained, lease time 43200
/etc/udhcpc.d/50default: Adding DNS 192.168.0.1
14 May 03:25:36 ntpdate[8614]: step time server 104.167.215.195 offset 1715655570.641238 sec
Starting ntpd: /usr/bin/ntpd is already running
1454
done
When it settles down, I see:
root@antMiner:/etc/rcS.d# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 34:E9:00:17:88:79
          inet addr:192.168.0.137  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:79 errors:0 dropped:1 overruns:0 frame:0
          TX packets:39 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:16783 (16.3 KiB)  TX bytes:6844 (6.6 KiB)
          Interrupt:54 Base address:0xb000
root@antMiner:/etc/rcS.d# date
Tue May 14 03:27:05 UTC 2024
How about that! It just works, and ntp works also (this was always a hurdle with the stupid angstrom linux setup on the BBB). In short, I am learning that Angstrom linux ain't all that bad if somebody sets it up right.

I add this entry to my desktop /etc/hosts file and I can ping "ant", but no ssh. I leave the cable plugged in and reboot, hoping it will start ssh. It does not.

I look at /etc/default/dropbear and see:

NO_START=1
I change this to a "0" and reboot again. That does it! Now dropbear (our ssh server) is running, but I get this familiar message:
ssh ant
Unable to negotiate with 192.168.0.137 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1
The fix is the add some lines to my .ssh/config file:
Host ant
    KexAlgorithms +diffie-hellman-group1-sha1
But this doesn't quite do it, now I get:
ssh ant
Unable to negotiate with 192.168.0.137 port 22: no matching host key type found. Their offer: ssh-rsa
And finally we try this (note: no dss key):
Host ant
    KexAlgorithms +diffie-hellman-group1-sha1
    HostKeyAlgorithms=+ssh-rsa
    PubkeyAcceptedAlgorithms=+ssh-rsa
And get:
ssh ant
Bad server host key: Invalid key length
The problem now is the server key is too short (less than 1024) and the only fix is to generate a longer key on the server side. The keys would seem to be in /var/lib/dropbear, and we have:
  DROPBEAR_RSAKEY_DEFAULT="/config/dropbear_rsa_host_key"
  DROPBEAR_DSSKEY_DEFAULT="/config/dropbear_dss_host_key"
We only see the RSA key here and it is a 426 byte file. We can use "dropbearkey" to generate a new key. We do do, using:
dropbearkey -t rsa -f key2.key -s 2048
We copy this into /config/dropbear_rsa_host_key, reboot to restart dropbear and it works!!

This page gives some help:


Feedback? Questions? Drop me a line!

Tom's Computer Info / [email protected]