2022-10-10 08:21:17 -04:00
|
|
|
#!/usr/bin/env bash
|
2022-07-15 08:48:35 -04:00
|
|
|
|
2022-11-10 04:28:35 -05:00
|
|
|
set -euo pipefail
|
|
|
|
shopt -s inherit_errexit
|
|
|
|
|
2022-11-10 08:17:04 -05:00
|
|
|
SCRIPTDIR="$(dirname -- "$(realpath "${BASH_SOURCE[0]}")")"
|
2022-07-15 08:48:35 -04:00
|
|
|
RG=$(jq -r .azureresourcegroup constellation-state.json)
|
|
|
|
SUBNET=$(jq -r .azuresubnet constellation-state.json)
|
|
|
|
VNET=${SUBNET%"/subnets/nodeNetwork"}
|
|
|
|
PUBKEY=$(cat ~/.ssh/id_rsa.pub)
|
|
|
|
DEPLOYMENT_NAME=jump-host
|
|
|
|
VM_NAME=jump-host
|
|
|
|
|
|
|
|
az deployment group create \
|
2022-11-10 08:17:04 -05:00
|
|
|
-o none \
|
|
|
|
--name "${DEPLOYMENT_NAME}" \
|
|
|
|
--resource-group "${RG}" \
|
|
|
|
--template-file "${SCRIPTDIR}/template.json" \
|
|
|
|
--parameters "@${SCRIPTDIR}/parameters.json" \
|
|
|
|
--parameters "{ \"virtualNetworkId\": { \"value\": \"${VNET}\" } }" \
|
|
|
|
--parameters "{ \"subnetRef\": { \"value\": \"${SUBNET}\" } }" \
|
|
|
|
--parameters "{ \"adminPublicKey\": { \"value\": \"${PUBKEY}\" } }"
|
2022-07-15 08:48:35 -04:00
|
|
|
az deployment group wait --created --name "${DEPLOYMENT_NAME}" --resource-group "${RG}"
|
2022-11-10 08:17:04 -05:00
|
|
|
PUBIP=$(
|
|
|
|
az vm list-ip-addresses \
|
|
|
|
--resource-group "${RG}" \
|
|
|
|
--name "${VM_NAME}" \
|
|
|
|
--query "[].virtualMachine.network.publicIpAddresses[0].ipAddress" \
|
|
|
|
--output tsv
|
|
|
|
)
|
2022-07-15 08:48:35 -04:00
|
|
|
echo "Jump host created. Cleanup by deleteing the resource group."
|
|
|
|
echo "Connect to the jump host with the following command:"
|
|
|
|
echo -e "ssh azureuser@${PUBIP}\n"
|
|
|
|
echo "Expose any nodes's debugd port locally:"
|
|
|
|
echo -e "NODEIP=<IP OF CONSTELLATION NODE> && \n\
|
|
|
|
ssh -M -S debugd -fNT -L \"4000:\${NODEIP}:4000\" azureuser@${PUBIP} && \n\
|
|
|
|
./cdbg deploy --ips localhost && \n\
|
|
|
|
ssh -S debugd -O exit azureuser@${PUBIP}\n"
|
|
|
|
echo "Connect to any constellation node using the following command:"
|
|
|
|
echo "ssh -J azureuser@${PUBIP} <USER>@<IP OF CONSTELLATION NODE>"
|