Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

private_key ressource import corrumption to execute sshj-ssh commands .... Cannot invoke "net.schmizz.sshj.userauth.keyprovider.KeyProvider.getPublic()" because "this.kProv" is null #125

Open
mdelagliere opened this issue Apr 10, 2024 · 1 comment

Comments

@mdelagliere
Copy link

Hi there,

Terraform Version

Terraform v1.7.5
on linux_amd64

  • provider registry.terraform.io/hashicorp/local v2.5.1
  • provider registry.terraform.io/hashicorp/null v3.2.2
  • provider registry.terraform.io/hashicorp/template v2.2.0
  • provider registry.terraform.io/rundeck/rundeck v0.4.7

Affected Resource(s)

  • rundeck_private_key

terraform {
required_providers {
rundeck = {
source = "rundeck/rundeck"
version = "0.4.7"
}
}
}

resource "rundeck_private_key" "id_rsa_test" {
path = "project/terraform/id_rsa_test.pem"
key_material = "$${file("/home/USERHOME/.ssh/id_rsa_test.pem")}"
}
resource "rundeck_project" "terraform" {
name = var.nom_projet
description = var.description_projet

Utilisation d'un chemin unique pour stocker les clés SSH

ssh_key_storage_path = "keys/${rundeck_private_key.id_rsa_test.path}"
default_node_executor_plugin = "sshj-ssh"

 resource_model_source {
   type = "file"
   config = {
       format = "resourceyaml"
       file = "/var/lib/rundeck/remote-node.yml"
       writable = true
       generateFileAutomatically = "false"
       ssh_authentication_type = "privateKey"
   }

}

extra_config = {
"project.label" = var.label_projet
"project.ssh-authentication" = "privateKey"
"project.ssh-key-storage-path" = "keys/project/terraform/id_rsa_test.pem"
"resources.source.1.config.file" = "/var/lib/rundeck/remote-node.yml"
"resources.source.1.config.format" = "resourceyaml"
"resources.source.1.config.generateFileAutomatically" = "false"
"resources.source.1.config.ssh_authentication_type" = "privateKey"
"resources.source.1.config.writable" = "true"
"resources.source.1.type" = "file"
"service.FileCopier.default.provider" = "sshj-scp"
"service.NodeExecutor.default.provider" = "sshj-ssh"
}
}

from commands'project menu :

Failed: Unknown: Cannot invoke "net.schmizz.sshj.userauth.keyprovider.KeyProvider.getPublic()" because "this.kProv" is null
Execution failed: 34 in project terraform: [Workflow result: , step failures: {1=Dispatch failed on 1 nodes: [remote-node: Unknown: Cannot invoke "net.schmizz.sshj.userauth.keyprovider.KeyProvider.getPublic()" because "this.kProv" is null + {dataContext=MultiDataContextImpl(map={ContextView(node:remote-node)=BaseDataContext{{exec={exitCode=-1}}}, ContextView(step:1, node:remote-node)=BaseDataContext{{exec={exitCode=-1}}}}, base=null)} ]}, Node failures: {remote-node=[Unknown: Cannot invoke "net.schmizz.sshj.userauth.keyprovider.KeyProvider.getPublic()" because "this.kProv" is null + {dataContext=MultiDataContextImpl(map={ContextView(node:remote-node)=BaseDataContext{{exec={exitCode=-1}}}, ContextView(step:1, node:remote-node)=BaseDataContext{{exec={exitCode=-1}}}}, base=null)} ]}, status: failed]

to soluce that, i overwrite key from gui menu key storage with

-----BEGIN RSA PRIVATE KEY-----
MIIJKAIBAAKCAgEA0KkNQEihbMdmXFetDgVxh3q++zSzDbor2EYx7HHN6TZNpg/N
-----END RSA PRIVATE KEY-----
and when i did that, command menu it does work well ....

i need help

remote-node.yml :
remote-node:
description: Remote SSH Swarm Server
hostname: IP_OF_REMOTE
nodename: swarm-manager
osArch: amd64
osFamily: unix
osName: Linux
osVersion: 5.15.0-89-generic
tags: 'swarm'
username: michael
ssh-key-storage-path: keys/project/terraform/id_rsa_test.pem

@fdevans
Copy link
Contributor

fdevans commented Sep 24, 2024

Sorry, I'm not following what the issue is here. Can you please provide more detail?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants