Search code examples
terraformoracle-cloud-infrastructureterraform-provider-ocioracle-cloud-shell

Getting the error in terraform code while trying to connect to linux server in OCI cloud shell . ------Failed to read ssh private key: no key found


Getting the error in terraform code while trying to connect to linux server in OCI cloud shell . ------Failed to read ssh private key: no key found Below is my code : -


resource "null_resource" "remote-exec" {
        
    
    provisioner "remote-exec" {
        connection {
            agent = false
            timeout = "10m"
            host ="xx.xx.x.x" 
            user = var.host_user_name
            private_key =file("${path.module}/integerebspvtkey.ssh.ppk")
        }
        inline = [
            ...
        ]
    }
    }



    variable "host_user_name"{
          default="opc"
    }

integerebspvtkey.ssh.ppk is the private key present in the same directory from where I am running the terraform


Solution

  • Based on the comments.

    The issue was wrong format of the key. Instead of ppk, it should be pem.