Skip to content

Instantly share code, notes, and snippets.

@VasiliyS
Created September 21, 2021 21:44
Show Gist options
  • Save VasiliyS/ab24c7418dbb11f904128ed2d421eb92 to your computer and use it in GitHub Desktop.
Save VasiliyS/ab24c7418dbb11f904128ed2d421eb92 to your computer and use it in GitHub Desktop.
Use Oracle Cloud Metadata to set-up a Flatcar instance
#!/bin/bash
echo "Getting metadata ..."
read -d '' Name Key <<< $(/usr/bin/curl -s -H "Authorization: Bearer Oracle" -L http://169.254.169.254/opc/v2/instance/ | /usr/bin/jq -r ' .hostname,.metadata.ssh_authorized_keys')
#set the hostname
echo "Setting hostname to $Name"
/usr/bin/hostnamectl set-hostname $Name
echo "Updating authorized keys..."
#put SSH keys
echo $Key > /home/core/.ssh/authorized_keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment