Compare commits
38 Commits
99b477d109
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c4339f22d | |||
| 1e764719ca | |||
| 9e92254492 | |||
| 3a5333330c | |||
| da9be91d51 | |||
| 9daa35178f | |||
| 8427663d71 | |||
| 22472c633d | |||
| 20bf6afee4 | |||
| 6b4079c065 | |||
| 10ca1a3b5c | |||
| bf661b5cf7 | |||
| 2d1c671e58 | |||
| debd5d30b5 | |||
| 075ef91fa0 | |||
| 0dc50a4d0d | |||
| ddd9877848 | |||
| 449e7f690a | |||
| fb864eb52f | |||
| 34b794cca2 | |||
| d86d95dcfd | |||
| 8eeee5de18 | |||
| 2178ba7641 | |||
| c9f4e03e84 | |||
| f176be5ddb | |||
| 776f97605e | |||
| f53209203a | |||
| 82ea0b2162 | |||
| a1aa960099 | |||
| ec7d57159d | |||
| a5fed4a656 | |||
| e731c0ac77 | |||
| d7eae1c535 | |||
| 2edbeac212 | |||
| 0b95ba72b3 | |||
| 51cb4aa795 | |||
| 3be9e45fac | |||
| 25859647f9 |
24
Dockerfile
24
Dockerfile
@@ -4,27 +4,26 @@ FROM debian:bookworm-slim
|
|||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
# Update and install Swiss Army Knife tools
|
# Update and install Swiss Army Knife tools
|
||||||
RUN apt-get update && apt-get install -y curl wget git jq unzip tar vim nano python3 python3-pip python3-venv build-essential iputils-ping dnsutils net-tools nodejs npm ffmpeg openssh-server sudo && rm -rf /var/lib/apt/lists/*
|
RUN apt-get update && apt-get install -y curl wget git jq unzip tar vim nano python3 python3-pip python3-venv build-essential iputils-ping dnsutils net-tools nodejs npm ffmpeg openssh-server ripgrep ncdu sudo && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install yq (binary release for latest version)
|
# Install yq (binary release for latest version)
|
||||||
RUN wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq
|
RUN wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq
|
||||||
|
RUN wget https://downloads-openshift-console.apps.lab.apilab.us/amd64/linux/oc.tar -O /tmp/oc.tar && tar -xvf /tmp/oc.tar -C /usr/bin/ && rm /tmp/oc.tar && chmod +x /usr/bin/oc
|
||||||
|
|
||||||
# Setup SSH directory & Config for OpenShift (Random UID support)
|
# Setup SSH directory & Config for OpenShift (Random UID support)
|
||||||
RUN mkdir -p /var/run/sshd && mkdir -p /etc/ssh/host_keys && chmod 775 /var/run/sshd && chmod 775 /etc/ssh/host_keys
|
RUN mkdir -p /var/run/sshd && chmod 775 /var/run/sshd
|
||||||
|
|
||||||
# Custom sshd_config for non-root usage
|
# Custom sshd_config for non-root usage
|
||||||
RUN echo "Port 2222\nPermitRootLogin no\nPasswordAuthentication no\nPubkeyAuthentication yes\nPidFile /var/run/sshd/sshd.pid\nHostKey /etc/ssh/host_keys/ssh_host_rsa_key\nHostKey /etc/ssh/host_keys/ssh_host_ecdsa_key\nHostKey /etc/ssh/host_keys/ssh_host_ed25519_key\nAuthorizedKeysFile .ssh/authorized_keys\nChallengeResponseAuthentication no\nUsePAM yes\nSubsystem sftp /usr/lib/openssh/sftp-server" > /etc/ssh/sshd_config
|
# StrictModes no: Required for non-root / random UID environments
|
||||||
|
# PidFile: Point to /tmp for guaranteed write access
|
||||||
|
RUN echo "Port 2222\nPermitRootLogin no\nPasswordAuthentication no\nPubkeyAuthentication yes\nStrictModes no\nPidFile /tmp/sshd.pid\nHostKey /data/ssh/ssh_host_rsa_key\nHostKey /data/ssh/ssh_host_ecdsa_key\nHostKey /data/ssh/ssh_host_ed25519_key\nAuthorizedKeysFile .ssh/authorized_keys\nChallengeResponseAuthentication no\nUsePAM yes\nSubsystem sftp /usr/lib/openssh/sftp-server" > /etc/ssh/sshd_config
|
||||||
|
|
||||||
# Create a user 'claw' with sudo access
|
# Create a user 'claw' (UID 1000) with sudo access
|
||||||
# Passwordless sudo allowed for friction-free automation
|
RUN useradd -m -s /bin/bash -u 1000 claw && echo "claw ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && chmod -R g+rwX /home/claw
|
||||||
# OpenShift runs as random UID, but 'claw' gives us a named user for direct exec if needed
|
|
||||||
# We also chmod the home dir to allow group access (OpenShift random UID runs as root group)
|
|
||||||
RUN useradd -m -s /bin/bash claw && echo "claw ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && chmod -R g+rwX /home/claw
|
|
||||||
|
|
||||||
# Prepare volume mount point
|
# Prepare volume mount point
|
||||||
# Mount persistent storage here
|
# Mount persistent storage here
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
# Critical for OpenShift: Allow root group (gid 0) to write to /data
|
|
||||||
RUN mkdir -p /data && chown claw:claw /data && chmod 775 /data
|
RUN mkdir -p /data && chown claw:claw /data && chmod 775 /data
|
||||||
|
|
||||||
# Set working directory to the persistent volume
|
# Set working directory to the persistent volume
|
||||||
@@ -33,6 +32,9 @@ WORKDIR /data
|
|||||||
# Expose SSH port (non-privileged)
|
# Expose SSH port (non-privileged)
|
||||||
EXPOSE 2222
|
EXPOSE 2222
|
||||||
|
|
||||||
|
# Switch to user 'claw' (UID 1000)
|
||||||
|
USER claw
|
||||||
|
|
||||||
# Start SSH daemon
|
# Start SSH daemon
|
||||||
# Generate host keys on startup if missing (for ephemeral pods)
|
# Fix: StrictModes no handles permissions, but chmod 600 helps sanity.
|
||||||
CMD ["/bin/bash", "-c", "ssh-keygen -A && /usr/sbin/sshd -D -f /etc/ssh/sshd_config"]
|
CMD ["/bin/bash", "-c", "mkdir -p /data/ssh && if [ ! -f /data/ssh/ssh_host_rsa_key ]; then echo 'Generating persistent host keys...'; ssh-keygen -f /data/ssh/ssh_host_rsa_key -N '' -t rsa; ssh-keygen -f /data/ssh/ssh_host_ecdsa_key -N '' -t ecdsa; ssh-keygen -f /data/ssh/ssh_host_ed25519_key -N '' -t ed25519; fi && chmod 600 /data/ssh/ssh_host_*_key && /usr/sbin/sshd -D -f /etc/ssh/sshd_config"]
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ apiVersion: apps/v1
|
|||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: clawdbox
|
name: clawdbox
|
||||||
|
namespace: clawdbox
|
||||||
labels:
|
labels:
|
||||||
app: clawdbox
|
app: clawdbox
|
||||||
spec:
|
spec:
|
||||||
@@ -16,10 +17,46 @@ spec:
|
|||||||
labels:
|
labels:
|
||||||
app: clawdbox
|
app: clawdbox
|
||||||
spec:
|
spec:
|
||||||
|
serviceAccountName: clawd-sa
|
||||||
|
initContainers:
|
||||||
|
- name: setup-ssh
|
||||||
|
image: docker.io/alpine:latest
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
# 1. Fix data volume permissions
|
||||||
|
chown -R 1000:0 /data && chmod -R 775 /data
|
||||||
|
|
||||||
|
# 2. Setup writable SSH tirectory from Secret
|
||||||
|
cp /mnt/keys/authorized_keys /working-ssh/
|
||||||
|
chown 1000:0 /working-ssh/authorized_keys
|
||||||
|
chmod 600 /working-ssh/authorized_keys
|
||||||
|
volumeMounts:
|
||||||
|
- name: data-volume
|
||||||
|
mountPath: /data
|
||||||
|
- name: ssh-keys-secret
|
||||||
|
mountPath: /mnt/keys
|
||||||
|
- name: ssh-working
|
||||||
|
mountPath: /working-ssh
|
||||||
containers:
|
containers:
|
||||||
- name: clawdbox
|
- name: clawdbox
|
||||||
image: image-registry.openshift-image-registry.svc:5000/clawdbox/clawdbox:latest
|
image: default-route-openshift-image-registry.apps.lab.apilab.us/clawdbox/clawdbox:latest
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
- "-c"
|
||||||
|
- |
|
||||||
|
mkdir -p /data/ssh
|
||||||
|
if [ ! -f /data/ssh/ssh_host_rsa_key ]; then
|
||||||
|
echo 'Generating persistent host keys...'
|
||||||
|
ssh-keygen -f /data/ssh/ssh_host_rsa_key -N '' -t rsa
|
||||||
|
ssh-keygen -f /data/ssh/ssh_host_ecdsa_key -N '' -t ecdsa
|
||||||
|
ssh-keygen -f /data/ssh/ssh_host_ed25519_key -N '' -t ed25519
|
||||||
|
fi
|
||||||
|
chmod 600 /data/ssh/ssh_host_*_key
|
||||||
|
# Run sshd with PAM disabled and logging to stderr
|
||||||
|
/usr/sbin/sshd -D -e -f /etc/ssh/sshd_config -o UsePAM=no
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 2222
|
- containerPort: 2222
|
||||||
name: ssh
|
name: ssh
|
||||||
@@ -27,26 +64,32 @@ spec:
|
|||||||
- mountPath: /data
|
- mountPath: /data
|
||||||
name: data-volume
|
name: data-volume
|
||||||
- mountPath: /home/claw/.ssh
|
- mountPath: /home/claw/.ssh
|
||||||
name: ssh-keys
|
name: ssh-working
|
||||||
|
- mountPath: /home/claw/.kube
|
||||||
|
name: kubeconfig-secret
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
memory: "2Gi"
|
memory: "1Gi"
|
||||||
cpu: "1000m"
|
cpu: "1000m"
|
||||||
requests:
|
requests:
|
||||||
memory: "512Mi"
|
memory: "128Mi"
|
||||||
cpu: "250m"
|
cpu: "250m"
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
runAsUser: 1000
|
||||||
|
runAsGroup: 1000
|
||||||
|
fsGroup: 1000
|
||||||
|
allowPrivilegeEscalation: true
|
||||||
capabilities:
|
capabilities:
|
||||||
drop: ["ALL"]
|
add: ["CAP_AUDIT_WRITE"]
|
||||||
runAsNonRoot: true
|
|
||||||
seccompProfile:
|
|
||||||
type: RuntimeDefault
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: data-volume
|
- name: data-volume
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: clawdbox-pvc
|
claimName: clawdbox-pvc
|
||||||
- name: ssh-keys
|
- name: ssh-keys-secret
|
||||||
secret:
|
secret:
|
||||||
secretName: clawdbox-ssh-keys
|
secretName: clawdbox-ssh-keys
|
||||||
defaultMode: 0600
|
- name: kubeconfig-secret
|
||||||
|
secret:
|
||||||
|
secretName: kube
|
||||||
|
- name: ssh-working
|
||||||
|
emptyDir: {}
|
||||||
|
|||||||
Reference in New Issue
Block a user