OpenShift SSH Client in a Pod
OpenShift SSH Client in a Pod
This is just conceptual.
$ mkdir ssh-test && cd ssh-test
$ echo 'FROM registry.access.redhat.com/rhel7:latest
USER root
RUN yum-config-manager --enable rhel-7-server-rpms && yum install openssh-clients -y' > Dockerfile
$ oc new-project ssh-test
$ oc new-build . --to ssh-test
$ oc start-build ssh-test --from-dir .
$ oc run -i -t ssh-test --image=172.30.1.1:5000/ssh-test/ssh-test --command -- /bin/bash
bash-4.2$ which ssh
bash-4.2$ exit
$ echo '<PRIVATE_KEY_FILE> id_rsa
$ echo '<KNOWN_HOSTS_FILE' > known_hosts
$ oc create secret generic id-key --from-file=id_rsa
$ oc create secret generic known-hosts --from-file=known_hosts
$ oc set volumes dc/ssh-test --add --name=id-key --type=secret --secret-name=id-key --mount-path=/ssh/id_rsa --default-mode='0600'
$ oc set volumes dc/ssh-test --add --name=known-hosts --type=secret --secret-name=known-hosts --mount-path=/ssh/known_hosts --default-mode='0600'
$ ssh -i /ssh/id_rsa/id_rsa user@remote.host.com -o UserKnownHostsFile=/ssh/known_hosts/known_hosts
$ oc patch dc ssh-test -p '{"spec":{"serviceAccountName"="mysa"}}'