Skip to content

Commit 3ccd1ae

Browse files
committed
Build toolchain
1 parent f5ecc43 commit 3ccd1ae

File tree

7 files changed

+116
-190
lines changed

7 files changed

+116
-190
lines changed

.github/workflows/build.yaml

+31-73
Original file line numberDiff line numberDiff line change
@@ -9,112 +9,70 @@ 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:
1616
name: Filter changes
1717
runs-on: ubuntu-latest
1818
outputs:
19-
toolchain_changed: ${{ steps.toolchain-changed-files.outputs.any_changed }}
20-
build_changed: ${{ steps.build-changed-files.outputs.any_changed }}
19+
build_changed: ${{ steps.build-files-changed.outputs.any_changed }}
2120
steps:
2221
- name: Checkout
2322
uses: actions/checkout@v4
2423

25-
- name: Toolchain Changed Files
26-
id: toolchain-changed-files
27-
uses: tj-actions/changed-files@v45
28-
with:
29-
files: |
30-
toolchain/**
31-
32-
- name: Build Changed Files
33-
id: build-changed-files
24+
- name: Build files changed
25+
id: build-files-changed
3426
uses: tj-actions/changed-files@v45
3527
with:
3628
files: |
3729
.github/workflows/build.yaml
3830
KoboRoot/**
39-
compile.sh
31+
Dockerfile
4032
41-
build-toolchain-image:
42-
if: ${{ needs.filter-changes.outputs.toolchain_changed == 'true' }}
43-
name: Build toolchain image
33+
build-koboroot:
34+
if: ${{ needs.filter-changes.outputs.build_changed == 'true' }}
35+
name: Build KoboRoot
4436
runs-on: ubuntu-latest
37+
needs:
38+
- filter-changes
4539
permissions:
46-
contents: read
47-
packages: write
40+
contents: write
41+
env:
42+
TOOLCHAIN_IMAGE: kobo-ssh-toolchain:latest
4843
steps:
4944
- name: Checkout
5045
uses: actions/checkout@v4
5146

5247
- name: Set up Docker Buildx
5348
uses: docker/setup-buildx-action@v3
5449

55-
- name: Login to image registry
56-
uses: docker/login-action@v3
57-
with:
58-
registry: ghcr.io
59-
username: ${{ github.actor }}
60-
password: ${{ github.token }}
61-
62-
- name: Docker meta
63-
id: meta
64-
uses: docker/metadata-action@v5
65-
with:
66-
images: |
67-
ghcr.io/${{ github.repository_owner }}/kobo-ssh-toolchain
68-
tags: |
69-
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
70-
type=ref,event=branch
71-
type=ref,event=tag
72-
7350
- name: Build image
7451
uses: docker/build-push-action@v6
7552
id: build
53+
env:
54+
DOCKER_BUILD_RECORD_UPLOAD: false
55+
DOCKER_BUILD_SUMMARY: false
7656
with:
77-
context: toolchain
78-
file: ./Dockerfile
79-
push: true
80-
tags: ${{ steps.meta.outputs.tags }}
81-
labels: ${{ steps.meta.outputs.labels }}
57+
push: false
58+
load: true
59+
tags: ${{ env.TOOLCHAIN_IMAGE }}
8260
cache-from: type=gha
8361
cache-to: type=gha,mode=max
8462

85-
build-koboroot:
86-
if: ${{ needs.filter-changes.outputs.build_changed == 'true' }}
87-
name: Build KoboRoot
88-
runs-on: ubuntu-latest
89-
needs:
90-
- filter-changes
91-
- build-toolchain-image
92-
permissions:
93-
contents: read
94-
packages: read
95-
env:
96-
TOOLCHAIN_IMAGE: ghcr.io/${{ github.repository_owner }}/kobo-ssh-toolchain:latest
97-
DROPBEAR_TAG: DROPBEAR_2025.87
98-
OPENSSH_TAG: V_9_9_P2
99-
steps:
100-
- name: Checkout
101-
uses: actions/checkout@v4
102-
103-
- name: Clone dropbear sources
104-
run: |
105-
git clone --depth 1 --branch "${{ env.DROPBEAR_TAG }}" https://github.com/mkj/dropbear.git external/dropbear
106-
107-
- name: Build dropbear
108-
uses: kohlerdominik/docker-run-action@v2
63+
- name: Fetch build output
64+
uses: kohlerdominik/[email protected]
10965
with:
11066
image: ${{ env.TOOLCHAIN_IMAGE }}
11167
volumes: |
112-
${{ github.workspace }}:/workspace
113-
workdir: /workspace
68+
${{ github.workspace }}/dist:/dist
11469
run: |
115-
export PATH="/root/x-tools/arm-kobo-linux-gnueabihf/bin:$PATH"
116-
autoconf
117-
autoheader
118-
./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
119-
make clean
120-
make PROGRAMS="dropbear dropbearkey" MULTI=1
70+
cp /output/KoboRoot.tgz /dist/
71+
72+
- name: Release artifact
73+
uses: softprops/action-gh-release@v2
74+
with:
75+
tag_name: "2025.87"
76+
body: |
77+
Dropbear 2025.87 for Kobo eReaders
78+
files: dist/KoboRoot.tgz

.gitignore

-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
1-
# Compiled binaries
2-
KoboRoot/usr/bin/dropbearmulti
3-
KoboRoot/usr/libexec/sftp-server
4-
5-
# Remote sources
6-
external/
71
# Generated files
82
dist/

Dockerfile

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM koreader/kokobo:0.3.6-20.04 AS build
2+
ENV PATH=/usr/local/x-tools/arm-kobo-linux-gnueabihf/bin:$PATH
3+
4+
ARG DROPBEAR_TAG="DROPBEAR_2025.87"
5+
ARG OPENSSH_TAG="V_9_9_P2"
6+
7+
WORKDIR /source
8+
RUN <<EOF
9+
git clone --branch "${DROPBEAR_TAG}" --depth 1 https://github.com/mkj/dropbear.git dropbear
10+
git clone --branch "${OPENSSH_TAG}" --depth 1 https://github.com/openssh/openssh-portable.git openssh-portable
11+
EOF
12+
13+
WORKDIR /source/dropbear
14+
COPY <<EOF localoptions.h
15+
#define DROPBEAR_MLKEM768 0
16+
#define DSS_PRIV_FILENAME "/usr/local/dropbear/dss_host_key"
17+
#define RSA_PRIV_FILENAME "/usr/local/dropbear/rsa_host_key"
18+
#define ECDSA_PRIV_FILENAME "/usr/local/dropbear/ecdsa_host_key"
19+
#define ED25519_PRIV_FILENAME "/usr/local/dropbear/ed25519_host_key"
20+
#define SFTPSERVER_PATH "/usr/bin/sftp-server"
21+
EOF
22+
23+
RUN <<EOF
24+
./configure --host=arm-kobo-linux-gnueabihf CC="arm-kobo-linux-gnueabihf"-gcc LD="arm-kobo-linux-gnueabihf"-ld --disable-zlib --disable-wtmp --disable-lastlog --disable-syslog --disable-utmpx --disable-utmp --disable-wtmpx --disable-loginfunc --disable-pututxline --disable-pututline --enable-bundled-libtom --disable-pam
25+
make clean
26+
make -j PROGRAMS="dropbear dropbearkey"
27+
EOF
28+
29+
WORKDIR /source/openssh-portable
30+
RUN <<EOF
31+
autoreconf
32+
./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
33+
make clean
34+
make -j sftp-server
35+
EOF
36+
37+
FROM ubuntu:latest
38+
WORKDIR /output
39+
COPY --chown=root:root KoboRoot /KoboRoot
40+
COPY --chown=root:root --chmod=777 --from=build /source/openssh-portable/sftp-server /KoboRoot/usr/bin/sftp-server
41+
COPY --chown=root:root --chmod=777 --from=build /source/dropbear/dropbear /KoboRoot/usr/bin/dropbear
42+
COPY --chown=root:root --chmod=777 --from=build /source/dropbear/dropbearkey /KoboRoot/usr/bin/dropbearkey
43+
44+
RUN <<EOF
45+
tar -cvzf KoboRoot.tgz -C /KoboRoot .
46+
rm -rf /KoboRoot
47+
EOF

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

compile.sh

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

4-
TOOLCHAIN_IMAGE="ghcr.io/bjw-s-labs/kobo-ssh-toolchain:latest"
5-
DROPBEAR_TAG="DROPBEAR_2025.87"
6-
OPENSSH_TAG="V_9_9_P2"
4+
TOOLCHAIN_IMAGE="kobo-ssh-toolchain:latest"
75

8-
# Download sources
9-
mkdir -p external
10-
11-
rm -rf external/dropbear
12-
git clone --branch "${DROPBEAR_TAG}" --depth 1 https://github.com/mkj/dropbear.git external/dropbear
13-
14-
rm -rf external/openssh-portable
15-
git clone --branch "${OPENSSH_TAG}" --depth 1 https://github.com/openssh/openssh-portable.git external/openssh-portable
16-
17-
# 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'
30-
31-
# 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'
36-
37-
# Build KoboRoot.tgz
38-
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
42-
43-
mkdir -p dist
44-
tar -cvzf dist/KoboRoot.tgz --exclude='.DS_Store' -C KoboRoot .
6+
docker buildx build --tag "${TOOLCHAIN_IMAGE}" . --load
7+
docker run --rm -it -v "${PWD}/dist:/dist" "${TOOLCHAIN_IMAGE}" bash -c "cp /output/KoboRoot.tgz /dist/"

toolchain/Dockerfile

-68
This file was deleted.

0 commit comments

Comments
 (0)