OCI Compute: implementing SSH Key Authentication when Deploying via Terraform
I'm migrating some code and Can someone help me understand I'm upgrading from an older version and I'm relatively new to this, so bear with me... I'm having trouble with SSH key authentication for an OCI Compute instance that I'm deploying using Terraform (version 1.3.0). After the instance is created, I want to SSH into it even though I configured the public key correctly in the Terraform script. Hereβs a snippet of my Terraform configuration: ```hcl resource "oci_core_instance" "example_instance" { availability_domain = data.oci_identity_availability_domains.example_availability_domains.availability_domains[0].name compartment_id = var.compartment_id shape = var.instance_shape display_name = "example-instance" create_vnic_details { subnet_id = var.subnet_id assign_public_ip = true } metadata = { "ssh_authorized_keys" = file("~/.ssh/id_rsa.pub") } } ``` I verified that the public key exists and is accessible by Terraform, and the private key permissions are set correctly (only readable by me). However, when I try to connect using the command: ```bash ssh -i ~/.ssh/id_rsa opc@<public_ip_of_instance> ``` I get the following behavior: ``` Permission denied (publickey). ``` I've also checked the network security group rules and they're set to allow SSH (port 22). I even tried using a different key pair, but the scenario continues. Is there something I might be missing with the SSH key configuration in Terraform? Any insights would be greatly appreciated. I'm working on a CLI tool that needs to handle this. I'm on macOS using the latest version of Hcl. Am I approaching this the right way? I'm working with Hcl in a Docker container on macOS. Am I approaching this the right way? How would you solve this?