added kubernetes - ssh client example
All checks were successful
/ ssh-server (push) Successful in 6s
/ ssh-client (push) Successful in 8s

This commit is contained in:
2025-11-23 12:08:53 +00:00
parent da190f7d76
commit d83c055d9f

View File

@@ -40,3 +40,58 @@ _(local machine without direct access to target-server)_
```bash
ssh -f -N -L localhost:8001:target-server:80 usr@jump-machine.local
```
### kubernetes - ssh client
```yaml
kind: Pod
metadata:
name: ssh-client
labels:
app: ssh-client
spec:
containers:
- name: ssh-client
image: git.limbosolutions.com/kb/ssh-client:latest
tty: true
command: ["bash", "-c"]
args:
- |
set -e
eval `ssh-agent`
ssh-keyscan -p ${SRV_PORT} -H ${SRV_HOST} > ~/.ssh/known_hosts
ssh ${SRV_HOST}@${SRV_USER} -p ${SRV_PORT} "ls -lah" && \
echo "INFO:Remote command executed!"
env:
- name: SRV_HOST
valueFrom:
secretKeyRef:
name: backup-secrets
key: SRV_HOST
- name: SRV_PORT
valueFrom:
secretKeyRef:
name: backup-secrets
key: SRV_PORT
- name: SRV_USER
valueFrom:
secretKeyRef:
name: backup-secrets
key: SRV_USER
volumeMounts:
- name: backup-secrets
subPath: SSH_PRIVATE_KEY
mountPath: /root/.ssh/id_ed25519
volumes:
- name: backup-secrets
secret:
secretName: backup-secrets
defaultMode: 0600
items:
- key: SSH_PRIVATE_KEY
path: SSH_PRIVATE_KEY
```