From d48cb0050b6483c8d3367ffa3c20171b489f112c Mon Sep 17 00:00:00 2001 From: Simon Kuenzer Date: Wed, 3 Sep 2025 21:47:38 +0200 Subject: [PATCH] feat(netutils): An Alpine-based image having SSH and net CLI utils Signed-off-by: Simon Kuenzer --- netutils/Dockerfile | 21 +++++++++++++++++++++ netutils/Kraftfile | 12 ++++++++++++ netutils/README.md | 37 +++++++++++++++++++++++++++++++++++++ netutils/dropbeard.sh | 18 ++++++++++++++++++ netutils/motd | 20 ++++++++++++++++++++ netutils/profile | 1 + 6 files changed, 109 insertions(+) create mode 100644 netutils/Dockerfile create mode 100644 netutils/Kraftfile create mode 100644 netutils/README.md create mode 100755 netutils/dropbeard.sh create mode 100644 netutils/motd create mode 100644 netutils/profile diff --git a/netutils/Dockerfile b/netutils/Dockerfile new file mode 100644 index 00000000..8da0e7f6 --- /dev/null +++ b/netutils/Dockerfile @@ -0,0 +1,21 @@ +FROM alpine:latest +WORKDIR / + +RUN set -xe; \ + apk update; \ + apk add --no-cache \ + socat \ + dropbear \ + tcpdump \ + iputils \ + traceroute \ + bind-tools \ + socat + +RUN echo "root:unikraft" | chpasswd + +COPY ./motd /etc/motd +COPY ./profile /etc/profile + +RUN mkdir -p /opt/unikraft +COPY ./dropbeard.sh /opt/unikraft/dropbeard.sh diff --git a/netutils/Kraftfile b/netutils/Kraftfile new file mode 100644 index 00000000..ae2fe410 --- /dev/null +++ b/netutils/Kraftfile @@ -0,0 +1,12 @@ +spec: v0.6 + +runtime: base-compat:latest + +labels: + cloud.unikraft.v1.instances/scale_to_zero.policy: "off" + cloud.unikraft.v1.instances/scale_to_zero.stateful: "false" + cloud.unikraft.v1.instances/scale_to_zero.cooldown_time_ms: 1000 + +rootfs: ./Dockerfile + +cmd: ["/opt/unikraft/dropbeard.sh"] diff --git a/netutils/README.md b/netutils/README.md new file mode 100644 index 00000000..91716ce4 --- /dev/null +++ b/netutils/README.md @@ -0,0 +1,37 @@ +# Netutils Example image + +This image contains a minimal user space environment based on Alpine Linux. +A SSH server is launched and a couple of essential networking tools such as +`nslookup`, `ping`, `traceroute`, `ip`, `socat`, and `tcpdump` are preloaded. + +To run this example on Unikraft Cloud, first [install the `kraft` CLI tool](https://unikraft.org/docs/cli). +Then clone this examples repository and `cd` into this directory, and invoke: + +```console +kraft cloud deploy +``` + +Alternatively, you can deploy the image accepting your public key by handing it over the `PUBKEY` +environment variable, for example: + +```console +kraft cloud deploy -e PUBKEY="$( cat $HOME/.ssh/id_rsa.pub )" +``` + +After deploying, you can connect to the console via SSH through a tunnel. +Run the command below: + +```console +kraft cloud tunnel 2222::22 +``` + +Then connect to the instance via SSH using (default password is `unikraft`): + +```console +ssh root@localhost -p 2222 +``` + +## Learn more + +- [Unikraft Cloud's Documentation](https://unikraft.cloud/docs/) +- [Building `Dockerfile` Images with `Buildkit`](https://unikraft.org/guides/building-dockerfile-images-with-buildkit) diff --git a/netutils/dropbeard.sh b/netutils/dropbeard.sh new file mode 100755 index 00000000..c4e2f76c --- /dev/null +++ b/netutils/dropbeard.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e +export HOME=/root + +mkdir -p "${HOME}" +chmod 700 "${HOME}" +cd "${HOME}" + +# Install public key if given by user +if test -n "${PUBKEY}"; then + mkdir -p "${HOME}/.ssh" + chmod 700 "${HOME}/.ssh" + echo "${PUBKEY}" >> "${HOME}/.ssh/authorized_keys" + chmod 600 "${HOME}/.ssh/authorized_keys" + unset PUBKEY +fi + +# Launch dropbear SSH server +exec /usr/sbin/dropbear -ERF diff --git a/netutils/motd b/netutils/motd new file mode 100644 index 00000000..158ef1d5 --- /dev/null +++ b/netutils/motd @@ -0,0 +1,20 @@ + _ :=: +| |:=: +| |__:=: UNIKRAFT + \_____/ CLOUD + +Welcome to Unikraft Cloud! + +This is the netutils example image, its user space +is built on Alpine Linux: . +For details about this image, visit: +. + +This image comes preloaded with essential networking +tools such as nslookup, ping, traceroute, ip, socat, +and tcpdump. Need more? Just install additional +packages using apk. But keep an eye on your free +RAM. + +Enjoy! + diff --git a/netutils/profile b/netutils/profile new file mode 100644 index 00000000..3d3caa31 --- /dev/null +++ b/netutils/profile @@ -0,0 +1 @@ +PS1='# '