1

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

Deepak
  • 13
  • 4
  • 1
    Are you sure it should be in `ppk` formatat, not `pem`? – Marcin Feb 22 '22 at 03:10
  • 2
    Hey, thanks a lot . i converted it to pem format , not getting this error now. But got stuck into another issue `null_resource.remote-exec: Still creating... [1m50s elapsed]` . getting timeout error while doing ssh – Deepak Feb 22 '22 at 05:39
  • No problem. I would suggest making new question for the new issue with timeout. Also acceptance of my answer would be appreciated. – Marcin Feb 22 '22 at 05:52

1 Answers1

1

Based on the comments.

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

Marcin
  • 215,873
  • 14
  • 235
  • 294