How to configure private key generated by PuTTYGen in Jenkins
Reading Time:
Reading Time:
Assume you have already create the public and private key using PuTTYGen
We need to connect Jenkins to the cloud server using this private SSH key , we assume that the public key is added to the server and is not within the scope of this article
Login to Jenkins and navigate to manage Jenkins
Scroll to‘Publish over SSH’ section
Click ‘Add’ button to add a new server SSH settings under ‘Publish over SSH’
Click ‘Advanced’ button to see the SSH and Authentication options
Click ‘Advanced’ button to add SSH key
Now go to PuTTYGen and load the existing private ppk file using import option
It will ask for the passphrase that was given during key generation(if not given we will not see this screen )
The SSH key will be loaded and we will see the public key that corresponds to the private key and now we need to convert this to open ssh format that is understood by Jenkins
Export key to OpenSSH format
Save the open ssh key file to‘some-filename-open-ssh-format’
We will see one additional file created in open ssh format and lets see its content and format
The content of the private open ssh format key file
Lets paste this content to Jenkins.
Lets test if we are able to connect , click the ‘Test Configuration’ button
Success message indicates that connection was successful , now we can publish over shh from Jenkins
If incorrect ssh key then connection will fail because of Authentication failure and we we will see this kind of a message
jenkins.plugins.publish_over.BapPublisherException: Failed to connect and initialize SSH connection. Message: [Failed to connect session for config [DO-cosmos-api-server-spring-boot-1]. Message [USERAUTH fail]]
If incorrect ssh key format then we will get the error message shown below
jenkins.plugins.publish_over.BapPublisherException: Failed to add SSH key. Message [invalid privatekey: [B@3ef89687]
We have seen how to create a open ssh format file using PuttyGen tool to configure Jenkins‘Publish over SSH’ for our cloud server connection