Skip to content

Commit f19d963

Browse files
author
Marcel Zapf
committed
update
1 parent 2ad9253 commit f19d963

5 files changed

Lines changed: 40 additions & 19 deletions

File tree

chart/templates/cm-entrypoint.yaml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,27 @@ data:
2323
ssh-keygen -t ed25519 -f /home/dev/ssh_keys/ssh_host_ed25519_key -N ''
2424
fi
2525
26-
# Correct permissions for SSH keys
2726
chmod 600 /home/dev/ssh_keys/ssh_host_*
27+
2828
echo "Ensuring run directory exists at /home/dev/run."
2929
mkdir -p /home/dev/run
3030
31+
echo "Currently running sshd processes:"
32+
ps aux | grep sshd
3133
32-
echo "Starting SSH service with host keys from /home/dev/ssh_keys on port 2222."
33-
/usr/sbin/sshd -D -d -e -f /etc/ssh/sshd_config \
34-
-o Port={{ .Values.service.targetPort }} \
35-
-o HostKey=/home/dev/ssh_keys/ssh_host_rsa_key \
36-
-o HostKey=/home/dev/ssh_keys/ssh_host_ecdsa_key \
37-
-o HostKey=/home/dev/ssh_keys/ssh_host_ed25519_key \
38-
-o PidFile=/home/dev/run/sshd.pid
34+
echo "Killing any existing sshd processes..."
35+
for pid in $(ps aux | grep sshd | grep -v grep | awk '{print $2}'); do
36+
echo "Killing sshd pid $pid"
37+
kill $pid
38+
done
3939
40-
if [ $? -ne 0 ]; then
41-
echo "Failed to start SSH service."
42-
else
43-
echo "SSH service started successfully."
44-
fi
40+
echo "Removing stale PID file if exists..."
41+
rm -f /home/dev/run/sshd.pid
4542
46-
# Keep the container running if no command is provided
47-
echo "No additional command provided, container will keep running."
48-
tail -f /dev/null
43+
echo "Starting SSH service..."
44+
exec /usr/sbin/sshd -D -f /etc/ssh/sshd_config \
45+
-o Port=2222 \
46+
-o HostKey=/home/dev/ssh_keys/ssh_host_ed25519_key \
47+
-o HostKey=/home/dev/ssh_keys/ssh_host_rsa_key \
48+
-o HostKey=/home/dev/ssh_keys/ssh_host_ecdsa_key \
49+
-o PidFile=/home/dev/run/sshd.pid

chart/templates/cm-pamconfig.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ .Release.Name }}-pam-config
6+
data:
7+
sshd: |
8+
auth sufficient pam_pubkey_auth.so
9+
auth required pam_permit.so
10+
account required pam_permit.so
11+
session required pam_permit.so

chart/templates/cm-sshconfig.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
apiVersion: v1
23
kind: ConfigMap
34
metadata:
@@ -6,7 +7,7 @@ data:
67
sshd_config: |
78
Port {{ .Values.service.targetPort }}
89
PermitRootLogin no
9-
PasswordAuthentication yes
10+
PasswordAuthentication no
1011
ChallengeResponseAuthentication no
1112
UsePAM yes
1213
X11Forwarding yes
@@ -15,3 +16,4 @@ data:
1516
Subsystem sftp /usr/lib/openssh/sftp-server
1617
UseDNS no
1718
PidFile /home/dev/run/sshd.pid
19+
PrintLastLog no

chart/templates/statefulset.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ spec:
4949
mountPath: /etc/ssh/sshd_config
5050
subPath: sshd_config
5151
readOnly: true
52+
- name: pam-config-volume
53+
mountPath: /etc/pam.d/sshd
54+
subPath: sshd
55+
readOnly: true
5256
resources: {{ toYaml .Values.resources | indent 10 }}
5357
volumes:
5458
- name: entrypoint-script
@@ -63,6 +67,10 @@ spec:
6367
configMap:
6468
name: {{ .Release.Name }}-sshd-config
6569
defaultMode: 0755
70+
- name: pam-config-volume
71+
configMap:
72+
name: {{ .Release.Name }}-pam-config
73+
defaultMode: 0755
6674
volumeClaimTemplates:
6775
- metadata:
6876
name: home-volume

chart/values.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
replicaCount: 1
22

33
image:
4-
source: ghcr.io/syntax3rror404/k8s-devmachine@sha256:11aa5c10407d658c55c001ddde9b5f6c778f97c6e86b0f2d2b6a48971cf72cf5
4+
source: ghcr.io/syntax3rror404/k8s-devmachine@sha256:b74d9fc455717bee5b6330ef892bc621c0cfccf3c2b95af5ea407624ed4cce95
55
pullPolicy: IfNotPresent
66

77
service:
@@ -20,7 +20,6 @@ ssh:
2020
authorizedKeys: |
2121
# Place auth keys here ...
2222
# ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCu...
23-
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBjYNgOeBJ+f0koBLJg7JzT2U9agAGqd/c1gZbVvCZrK
2423
securityContext:
2524
runAsNonRoot: true
2625
runAsUser: 1001

0 commit comments

Comments
 (0)