#!/bin/bash # SPDX-License-Identifier: Apache-2.0 # This script will populate ~/.ssh/conf.d/detee.conf with SSH data for all DeTEE VMs. # After running the script, you will be able to SSH into all VMs by using the hostname mkdir -p ~/.ssh/conf.d/ config="${HOME}/.ssh/conf.d/detee.conf" echo > "$config" export FORMAT=YAML process_vm() { vm_id="$1" local tmp="/tmp/detee_vm_ssh_details" detee-cli vm ssh $vm_id --just-print > $tmp || return { echo Host $(grep 'hostname: ' $tmp | awk '{ print $2 }' ) echo " User root" echo " Hostname $(grep 'ip: ' $tmp | awk '{ print $2 }' )" echo " Port $(grep 'port: ' $tmp | cut -d "'" -f2 )" echo } >> $config } detee-cli vm list | grep uuid | awk '{ print $NF}' | while IFS= read -r vm_id; do process_vm "$vm_id" done grep 'Include ~/.ssh/conf.d/*.conf' "${HOME}/.ssh/config" > /dev/null 2>&1 || echo 'Include ~/.ssh/conf.d/*.conf' >> "${HOME}/.ssh/config"