Ashish Mishra
Ashish Mishra

Reputation: 421

Jenkins ec2 plugin ssh keys

I have a groovy script which will configure AWS ec2 plugin with required data. I am able to configure all other inputs. I need to give private key in same region, is there any way that i can generate and configure this key in grrovy script. followed below document and template. https://gist.github.com/vrivellino/97954495938e38421ba4504049fd44ea https://github.com/jenkinsci/ec2-plugin/blob/master/src/main/java/hudson/plugins/ec2/SlaveTemplate.java

Upvotes: 0

Views: 965

Answers (2)

vkozyrev
vkozyrev

Reputation: 1978

I am not sure if this is the right answer to your question, but this is where Google led me when I wanted to decipher the private key for the EC2 Jenkins plugin. This worked for me with Jenkins 2.190.2.

import hudson.plugins.ec2.AmazonEC2Cloud
def cloud = Jenkins.instance.clouds.find { it instanceof AmazonEC2Cloud }
println cloud.getKeyPair().keyMaterial

Upvotes: 0

user_dev
user_dev

Reputation: 1431

This will help you to get Jenkins private keys:

EC2Cloud cloud = Jenkins.instance.clouds.find { it instanceof EC2Cloud }
KeyPair key_pair= cloud.getKeyPair()
private_key_text = key_pair.keyMaterial
def secret_key = hudson.util.Secret.decrypt(cloud.getSecretKey()).toString()

Upvotes: 1

Related Questions