|
| 1 | +# Adding SSH keys for VMWare |
| 2 | + |
| 3 | +Most installations of Container Linux on VMWare require an SSH key to access the machine. Use a [Container Linux Config][cl-config] with a valid SSH key and the [Config Transpiler][config-transpiler] to create the ignition config. Then pass that ignition config to the VMWare image’s VMX file to enable SSH access to the machine. |
| 4 | + |
| 5 | +Modify the VMX file to pass an [Ignition Config][ignition-config] containing at least one valid SSH key. |
| 6 | + |
| 7 | +First, follow the instructions to Boot with VMware Workstation 12 or VMware Fusion to create a VM. (Do not start / power on the the VM. These instructions will work only on the first boot.) |
| 8 | + |
| 9 | +Next, create and apply the SSH key: |
| 10 | + |
| 11 | +1. [Download Config Transpiler][download-ct]. |
| 12 | + |
| 13 | +2. Follow the instructions to [add an SSH public key][add-ssh] to the Container Linux Config (for example `id_rsa.pub`). |
| 14 | + |
| 15 | +``` |
| 16 | +passwd: |
| 17 | + users: |
| 18 | + - name: core |
| 19 | + ssh_authorized_keys: |
| 20 | + - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0g+ZTxC7weoIJLUafOgrm+h..." |
| 21 | +``` |
| 22 | + |
| 23 | +3. Use Config Transpiler to convert the Container Linux Config YAML to Ignition Config, then base64 encode the Ignition config. |
| 24 | + |
| 25 | +``` |
| 26 | +$ ./ct --in-file config.yaml | base64 |
| 27 | +``` |
| 28 | + |
| 29 | +Remove any newline characters from the encoded output. |
| 30 | + |
| 31 | +4. Open the VM’s VMX file in your favorite text editor, and add the base64 encoded Ignition Config to the VMWare image’s VMX file under Guestinfo as outlined in [Defining the Ignition config in Guestinfo][define-guestinfo]. |
| 32 | + |
| 33 | +``` |
| 34 | +guestinfo.coreos.config.data = "<<Output of the base64 encoded ignition file>>>" |
| 35 | +guestinfo.coreos.config.data.encoding = "base64" |
| 36 | +``` |
| 37 | + |
| 38 | +5. Save the VMX file and boot the VM for the first time. |
| 39 | + |
| 40 | +Once booted, use `$ ssh core@<<ip address>>` to SSH into the machine. If you haven’t added the SSH key to the SSH agent, specify the key using the `-i` flag: |
| 41 | + |
| 42 | +`$ ssh -i <<path to ssh public key>> core@<<ip address>>` |
| 43 | + |
| 44 | + |
| 45 | +[add-ssh]: https://coreos.com/os/docs/latest/migrating-to-clcs.html#ssh_authorized_keys |
| 46 | +[config-transpiler]: https://coreos.com/os/docs/latest/overview-of-ct.html |
| 47 | +[define-guestinfo]: https://coreos.com/os/docs/latest/booting-on-vmware.html#defining-the-ignition-config-in-guestinfo |
| 48 | +[download-ct]: https://github.com/coreos/container-linux-config-transpiler/releases/ |
| 49 | +[ignition-config]: https://coreos.com/os/docs/latest/provisioning.html#ignition-config |
| 50 | +[cl-config]: https://coreos.com/os/docs/latest/provisioning.html |
0 commit comments