summaryrefslogtreecommitdiff
path: root/default/steps/bootstrap/prepare_appliance.yaml
blob: 4f597c4445dba4bad4d236e8c527c8c17282ad37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
- insecure_ssh_key: $${kameleon_cwd}/insecure_ssh_key

- generate_ssh_keys:
  - check_cmd_local: ssh-keygen
  - exec_local: echo -e  'y\n' | ssh-keygen -q -t rsa -b 4096 -f $${insecure_ssh_key} -N ''
  - exec_local: cat $${insecure_ssh_key}

- inject_ssh_private_key:
  - check_cmd_local: virt-customize
  - exec_local: |
      virt-customize \
        -a $${image_disk}.$${image_format} \
        --run-command 'mkdir -p /root/.ssh' \
        --upload $${insecure_ssh_key}.pub:/root/.ssh/.kameleon_authorized_keys \
        --run-command 'touch /root/.ssh/authorized_keys' \
        --run-command 'cp /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bak' \
        --run-command 'cat /root/.ssh/.kameleon_authorized_keys >> /root/.ssh/authorized_keys' \
        --run-command 'chmod 700 /root/.ssh' \
        --run-command 'chmod -R go-rw /root/.ssh' \
        --run-command 'chown -R root:root /root/.ssh'
  - on_export_init:
    - exec_local: |
        virt-customize \
          -a $${image_disk}.$${image_format} \
          --run-command 'mv /root/.ssh/authorized_keys.bak /root/.ssh/authorized_keys' \
          --delete /root/.ssh/.kameleon_authorized_keys

- add_insecure_key_to_ssh_config:
  - on_checkpoint: redo
  - exec_local: |
      cat <<EOF >> $${ssh_config_file}
      IdentityFile $${insecure_ssh_key}
      EOF