Skip to content

Commit bba7485

Browse files
committed
Build toolchain
1 parent f5ecc43 commit bba7485

File tree

6 files changed

+112
-33
lines changed

6 files changed

+112
-33
lines changed

.github/workflows/build.yaml

+55-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
concurrency:
1111
group: build-kobo-ssh
12-
cancel-in-progress: true
12+
cancel-in-progress: false
1313

1414
jobs:
1515
filter-changes:
@@ -42,6 +42,8 @@ jobs:
4242
if: ${{ needs.filter-changes.outputs.toolchain_changed == 'true' }}
4343
name: Build toolchain image
4444
runs-on: ubuntu-latest
45+
needs:
46+
- filter-changes
4547
permissions:
4648
contents: read
4749
packages: write
@@ -83,38 +85,83 @@ jobs:
8385
cache-to: type=gha,mode=max
8486

8587
build-koboroot:
86-
if: ${{ needs.filter-changes.outputs.build_changed == 'true' }}
88+
if: ${{ !cancelled() && !failure() && needs.filter-changes.outputs.build_changed == 'true' }}
8789
name: Build KoboRoot
8890
runs-on: ubuntu-latest
8991
needs:
9092
- filter-changes
9193
- build-toolchain-image
9294
permissions:
93-
contents: read
95+
contents: write
9496
packages: read
9597
env:
9698
TOOLCHAIN_IMAGE: ghcr.io/${{ github.repository_owner }}/kobo-ssh-toolchain:latest
97-
DROPBEAR_TAG: DROPBEAR_2025.87
99+
DROPBEAR_VERSION: "2025.87"
98100
OPENSSH_TAG: V_9_9_P2
99101
steps:
100102
- name: Checkout
101103
uses: actions/checkout@v4
102104

105+
- name: Grab toolchain image
106+
run: |
107+
docker pull "${{ env.TOOLCHAIN_IMAGE }}"
108+
103109
- name: Clone dropbear sources
104110
run: |
105-
git clone --depth 1 --branch "${{ env.DROPBEAR_TAG }}" https://github.com/mkj/dropbear.git external/dropbear
111+
git clone --depth 1 --branch "DROPBEAR_${{ env.DROPBEAR_VERSION }}" https://github.com/mkj/dropbear.git external/dropbear
112+
113+
- name: Clone openssh-portable sources
114+
run: |
115+
git clone --depth 1 --branch "${{ env.OPENSSH_TAG }}" https://github.com/openssh/openssh-portable.git external/openssh-portable
116+
117+
- name: Set dropbear compilation options
118+
run: |
119+
cp build/dropbear/localoptions.h external/dropbear/localoptions.h
106120
107121
- name: Build dropbear
108-
uses: kohlerdominik/docker-run-action@v2
122+
uses: kohlerdominik/docker-run-action@v2.0.0
109123
with:
110124
image: ${{ env.TOOLCHAIN_IMAGE }}
111125
volumes: |
112-
${{ github.workspace }}:/workspace
126+
${{ github.workspace }}/external/dropbear:/workspace
113127
workdir: /workspace
114128
run: |
115129
export PATH="/root/x-tools/arm-kobo-linux-gnueabihf/bin:$PATH"
116130
autoconf
117131
autoheader
118132
./configure --host=arm-kobo-linux-gnueabihf --disable-zlib --disable-zlib CC="arm-kobo-linux-gnueabihf"-gcc LD="arm-kobo-linux-gnueabihf"-ld --disable-wtmp --disable-lastlog --disable-syslog --disable-utmpx --disable-utmp --disable-wtmpx --disable-loginfunc --disable-pututxline --disable-pututline --enable-bundled-libtom --disable-pam
119133
make clean
120-
make PROGRAMS="dropbear dropbearkey" MULTI=1
134+
make PROGRAMS="dropbear dropbearkey"
135+
136+
- name: Build sftp-server
137+
uses: kohlerdominik/[email protected]
138+
with:
139+
image: ${{ env.TOOLCHAIN_IMAGE }}
140+
volumes: |
141+
${{ github.workspace }}/external/openssh-portable:/workspace
142+
workdir: /workspace
143+
run: |
144+
export PATH="/root/x-tools/arm-kobo-linux-gnueabihf/bin:$PATH"
145+
autoconf
146+
autoheader
147+
./configure --host=arm-kobo-linux-gnueabihf --without-openssl --without-zlib --without-pam --without-xauth CC="arm-kobo-linux-gnueabihf"-gcc LD="arm-kobo-linux-gnueabihf"-ld
148+
make clean
149+
make sftp-server
150+
151+
- name: Build KoboRoot.tgz artifact
152+
run: |
153+
mkdir -p KoboRoot/usr/bin
154+
mv external/dropbear/dropbear KoboRoot/usr/bin/
155+
mv external/dropbear/dropbearkey KoboRoot/usr/bin/
156+
mv external/openssh-portable/sftp-server KoboRoot/usr/bin/
157+
158+
mkdir -p dist
159+
tar -cvzf dist/KoboRoot.tgz -C KoboRoot .
160+
161+
- name: Release artifact
162+
uses: softprops/action-gh-release@v2
163+
with:
164+
tag_name: ${{ env.DROPBEAR_VERSION }}
165+
body: |
166+
Dropbear ${DROPBEAR_VERSION} for Kobo eReaders
167+
files: dist/KoboRoot.tgz

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Compiled binaries
2-
KoboRoot/usr/bin/dropbearmulti
3-
KoboRoot/usr/libexec/sftp-server
2+
KoboRoot/usr/bin/dropbear
3+
KoboRoot/usr/bin/dropbearkey
4+
KoboRoot/usr/bin/sftp-server
45

56
# Remote sources
67
external/

KoboRoot/usr/local/dropbear/on-boot.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
case "$(pidof dropbear | wc -w)" in
44
# Add the desired dropbear options here
5-
0) dropbearmulti dropbear -R -F -K 15 -s &
5+
0) dropbear -R -F -K 15 &
66
;;
77
*) ;;
88
esac

README.md

+34-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,36 @@
11
# kobo-ssh
2-
Build pipeline to compile Dropbear for Kobo
32

4-
Based on the work of https://github.com/obynio/kobopatch-ssh
3+
This repository contains the tools needed to compile [dropbear](https://matt.ucc.asn.au/dropbear/dropbear.html) and [sftp-server](https://github.com/openssh/openssh-portable) for the `arm-kobo-linux-gnueabihf` system (all recent [Kobo](https://www.kobo.com/) products).
4+
This binary is used for root shell access on Kobo devices which, in my case, is used to deploy and debug software on e-readers. As of now, these binaries have been tested on a Kobo Libra H2o and a Kobo Libra 2.
5+
6+
### Features:
7+
- Recent Dropbear version
8+
- `scp` to the SSH server works
9+
- Host keys will be generated automatically as required.
10+
11+
## Compiling locally
12+
13+
This project can be compiled locally by building the [toolchain container image](toolchain/Dockerfile) and then running the `compile.sh` script.
14+
15+
```sh
16+
docker buildx build --tag kobo-ssh-toolchain:latest ./toolchain --load
17+
./compile.sh
18+
```
19+
20+
This will compile all the required binaries and generate a `dist/KoboRoot.tgz` file.
21+
22+
## Prebuilt binaries
23+
24+
A prebuilt KoboRoot.tgz can be found on the [releases page](https://github.com/bjw-s-labs/kobo-ssh/releases).
25+
26+
## Kobo setup
27+
28+
Once you have generated the `KoboRoot.tgz` file you can transfer this to your Kobo device by connecting the device to your computer and placing the file in the `.kobo` folder on the exposed drive.
29+
30+
Finally, disconnect the device from your computer and wait for it to restart. Once the restart is complete you should have a working SSH server.
31+
32+
## Credits
33+
34+
Many thanks to the following for their original work on this subject:
35+
- https://github.com/Ewpratten/KoboSSH
36+
- https://github.com/obynio/kobopatch-ssh

build/dropbear/localoptions.h

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#define DROPBEAR_MLKEM768 0
2+
#define DSS_PRIV_FILENAME "/usr/local/dropbear/dss_host_key"
3+
#define RSA_PRIV_FILENAME "/usr/local/dropbear/rsa_host_key"
4+
#define ECDSA_PRIV_FILENAME "/usr/local/dropbear/ecdsa_host_key"
5+
#define ED25519_PRIV_FILENAME "/usr/local/dropbear/ed25519_host_key"
6+
#define SFTPSERVER_PATH "/usr/bin/sftp-server"

compile.sh

+13-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
TOOLCHAIN_IMAGE="ghcr.io/bjw-s-labs/kobo-ssh-toolchain:latest"
4+
TOOLCHAIN_IMAGE="kobo-ssh-toolchain:latest"
55
DROPBEAR_TAG="DROPBEAR_2025.87"
66
OPENSSH_TAG="V_9_9_P2"
77

@@ -15,30 +15,23 @@ rm -rf external/openssh-portable
1515
git clone --branch "${OPENSSH_TAG}" --depth 1 https://github.com/openssh/openssh-portable.git external/openssh-portable
1616

1717
# Compile Dropbear
18-
cat > external/dropbear/localoptions.h<< EOF
19-
#define DROPBEAR_MLKEM768 0
20-
#define DSS_PRIV_FILENAME "/usr/local/dropbear/dss_host_key"
21-
#define RSA_PRIV_FILENAME "/usr/local/dropbear/rsa_host_key"
22-
#define ECDSA_PRIV_FILENAME "/usr/local/dropbear/ecdsa_host_key"
23-
#define ED25519_PRIV_FILENAME "/usr/local/dropbear/ed25519_host_key"
24-
EOF
25-
26-
docker run --platform linux/amd64 -v "${PWD}/external/dropbear:/work" "${TOOLCHAIN_IMAGE}" /bin/bash -c 'cd /work; autoconf; autoheader'
27-
docker run --platform linux/amd64 -v "${PWD}/external/dropbear:/work" "${TOOLCHAIN_IMAGE}" /bin/bash -c 'export PATH="/root/x-tools/arm-kobo-linux-gnueabihf/bin:$PATH"; cd /work; ./configure --host=arm-kobo-linux-gnueabihf --disable-zlib --disable-zlib CC="arm-kobo-linux-gnueabihf"-gcc LD="arm-kobo-linux-gnueabihf"-ld --disable-wtmp --disable-lastlog --disable-syslog --disable-utmpx --disable-utmp --disable-wtmpx --disable-loginfunc --disable-pututxline --disable-pututline --enable-bundled-libtom --disable-pam'
28-
docker run --platform linux/amd64 -v "${PWD}/external/dropbear:/work" "${TOOLCHAIN_IMAGE}" /bin/bash -c 'export PATH="/root/x-tools/arm-kobo-linux-gnueabihf/bin:$PATH"; cd /work; make clean'
29-
docker run --platform linux/amd64 -v "${PWD}/external/dropbear:/work" "${TOOLCHAIN_IMAGE}" /bin/bash -c 'export PATH="/root/x-tools/arm-kobo-linux-gnueabihf/bin:$PATH"; cd /work; make PROGRAMS="dropbear dropbearkey" MULTI=1'
18+
cp build/dropbear/localoptions.h external/dropbear/localoptions.h
19+
docker run -v "${PWD}/external/dropbear:/work" "${TOOLCHAIN_IMAGE}" /bin/bash -c 'cd /work; autoconf; autoheader'
20+
docker run -v "${PWD}/external/dropbear:/work" "${TOOLCHAIN_IMAGE}" /bin/bash -c 'export PATH="/root/x-tools/arm-kobo-linux-gnueabihf/bin:$PATH"; cd /work; ./configure --host=arm-kobo-linux-gnueabihf --disable-zlib --disable-zlib CC="arm-kobo-linux-gnueabihf"-gcc LD="arm-kobo-linux-gnueabihf"-ld --disable-wtmp --disable-lastlog --disable-syslog --disable-utmpx --disable-utmp --disable-wtmpx --disable-loginfunc --disable-pututxline --disable-pututline --enable-bundled-libtom --disable-pam'
21+
docker run -v "${PWD}/external/dropbear:/work" "${TOOLCHAIN_IMAGE}" /bin/bash -c 'export PATH="/root/x-tools/arm-kobo-linux-gnueabihf/bin:$PATH"; cd /work; make clean'
22+
docker run -v "${PWD}/external/dropbear:/work" "${TOOLCHAIN_IMAGE}" /bin/bash -c 'export PATH="/root/x-tools/arm-kobo-linux-gnueabihf/bin:$PATH"; cd /work; make PROGRAMS="dropbear dropbearkey"'
3023

3124
# Compile sftp-server
32-
docker run --platform linux/amd64 -v "${PWD}/external/openssh-portable:/work" "${TOOLCHAIN_IMAGE}" /bin/bash -c 'cd /work; autoconf; autoheader'
33-
docker run --platform linux/amd64 -v "${PWD}/external/openssh-portable:/work" "${TOOLCHAIN_IMAGE}" /bin/bash -c 'export PATH="/root/x-tools/arm-kobo-linux-gnueabihf/bin:$PATH"; cd /work; ./configure --host=arm-kobo-linux-gnueabihf --without-openssl --without-zlib --without-pam --without-xauth CC="arm-kobo-linux-gnueabihf"-gcc LD="arm-kobo-linux-gnueabihf"-ld'
34-
docker run --platform linux/amd64 -v "${PWD}/external/openssh-portable:/work" "${TOOLCHAIN_IMAGE}" /bin/bash -c 'export PATH="/root/x-tools/arm-kobo-linux-gnueabihf/bin:$PATH"; cd /work; make clean'
35-
docker run --platform linux/amd64 -v "${PWD}/external/openssh-portable:/work" "${TOOLCHAIN_IMAGE}" /bin/bash -c 'export PATH="/root/x-tools/arm-kobo-linux-gnueabihf/bin:$PATH"; cd /work; make sftp-server'
25+
docker run -v "${PWD}/external/openssh-portable:/work" "${TOOLCHAIN_IMAGE}" /bin/bash -c 'cd /work; autoconf; autoheader'
26+
docker run -v "${PWD}/external/openssh-portable:/work" "${TOOLCHAIN_IMAGE}" /bin/bash -c 'export PATH="/root/x-tools/arm-kobo-linux-gnueabihf/bin:$PATH"; cd /work; ./configure --host=arm-kobo-linux-gnueabihf --without-openssl --without-zlib --without-pam --without-xauth CC="arm-kobo-linux-gnueabihf"-gcc LD="arm-kobo-linux-gnueabihf"-ld'
27+
docker run -v "${PWD}/external/openssh-portable:/work" "${TOOLCHAIN_IMAGE}" /bin/bash -c 'export PATH="/root/x-tools/arm-kobo-linux-gnueabihf/bin:$PATH"; cd /work; make clean'
28+
docker run -v "${PWD}/external/openssh-portable:/work" "${TOOLCHAIN_IMAGE}" /bin/bash -c 'export PATH="/root/x-tools/arm-kobo-linux-gnueabihf/bin:$PATH"; cd /work; make sftp-server'
3629

3730
# Build KoboRoot.tgz
3831
mkdir -p KoboRoot/usr/bin
39-
mv external/dropbear/dropbearmulti KoboRoot/usr/bin/dropbearmulti
40-
mkdir -p KoboRoot/usr/libexec
41-
mv external/openssh-portable/sftp-server KoboRoot/usr/libexec/sftp-server
32+
mv external/dropbear/dropbear KoboRoot/usr/bin/
33+
mv external/dropbear/dropbearkey KoboRoot/usr/bin/
34+
mv external/openssh-portable/sftp-server KoboRoot/usr/bin/
4235

4336
mkdir -p dist
4437
tar -cvzf dist/KoboRoot.tgz --exclude='.DS_Store' -C KoboRoot .

0 commit comments

Comments
 (0)