diff --git a/README.md b/README.md index ba98ceb..ef73f71 100644 --- a/README.md +++ b/README.md @@ -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 +```