Mount SSH configuration

Mount custom SSH configurations into workspaces by using a ConfigMap. Extend the default SSH settings with additional parameters or host-specific configurations.

Before you begin

About this task

Note

The system sets the default SSH configuration automatically from the SSH secret in User Preferences. You can extend it by mounting an additional .conf file to /etc/ssh/ssh_config.d/.

Procedure

  1. Create a ConfigMap with the SSH configuration:
    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: workspace-userdata-sshconfig-configmap
      namespace: <your_namespace>
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-configmap: 'true'
      annotations:
        controller.devfile.io/mount-as: subpath
        controller.devfile.io/mount-path: /etc/ssh/ssh_config.d/
    data:
      ssh-config.conf: |
        <ssh_config_content>

    where:

    <your_namespace>
    Your project name. To find your project, go to https://__<openshift_dev_spaces_fqdn>__/api/kubernetes/namespace.
    <ssh_config_content>
    The SSH configuration file content, for example Host, IdentityFile, or ProxyCommand directives.
  2. Apply the ConfigMap:
    oc apply -f - <<EOF
    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: workspace-userdata-sshconfig-configmap
      namespace: <your_namespace>
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-configmap: 'true'
      annotations:
        controller.devfile.io/mount-as: subpath
        controller.devfile.io/mount-path: /etc/ssh/ssh_config.d/
    data:
      ssh-config.conf: |
        <ssh_config_content>
    EOF

Results

  • Start a workspace and verify the SSH configuration file is mounted:
    $ cat /etc/ssh/ssh_config.d/ssh-config.conf