Local-exec not working with simple Open ssh commands

Hello,

I’ve a strange issue with the local-exec provisioner: I’m trying to execute simple Open SSH commands (like ssh-keygen or scp) and I’m getting a command not found error.

null_resource.clean_ssh (local-exec): operable program or batch file.

│ Error: local-exec provisioner error

│ with null_resource.clean_ssh,
│ on main.tf line 2, in resource “null_resource” “clean_ssh”:
│ 2: provisioner “local-exec” {

│ Error running command ’ ssh-keygen
│ ': exit status 1. Output: ‘ssh-keygen’ is not recognized as an internal or external command,
│ operable program or batch file.


PS C:\dev\ese-kmps\aws\Terraform\test> ssh-keygen
Generating public/private rsa key pair.

But in the same Windows Shell (command or PowerShell) the command can be executed.

I’ve checked the PATH and the %SystemRoot%\system32\OpenSSH\ is available. I’ve wrote a simple script to test the issue:

resource “null_resource” “clean_ssh” {
provisioner “local-exec” {
on_failure = fail
command = <<EOF
ssh-keygen
EOF
}
}

Any clues or points to check?
BR
Pascal

Change

to

command = "ssh-keygen"

You have extra carriage-return/new-line characters in your command string which are messing things up.

Found the fix: I’ve installed the wrong Terraform binary ?!? running smoothly with AMD64 and latest version of Terraform.
Sorry for the disturbance.
Pascal