Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Publish over ssh authentification failed with private key

I can authenticate successfully with putty on the server with my private key and passphrase. But when I try to do it with jenkins publish over SSH plugin (using Test for configuration), I get the following error message:

jenkins.plugins.publish_over.BapPublisherException: Failed to connect session for config myconfig. Message [Auth fail]

I entered the same information as in putty:

Hostname : myhostname
Username : myusername
Remote Directory :

Use password authentication, or use a different key Passphrase / Password Path to key : checked
Path to key : mypath
Passphrase : mypasssword
Key:
Port:22
Timeout(ms):300000

If you have any idea ... Thanks for your help.

like image 658
Corinne Kubler Avatar asked Mar 12 '14 08:03

Corinne Kubler


People also ask

What is publish over SSH in Jenkins?

sshPublisher : Send build artifacts over SSH. Send files or execute commands over SSH. alwaysPublishFromMaster : boolean (optional) Select to publish from the Jenkins master. The default is to publish from the server that holds the files to transfer (workspace on the agent, or artifacts directory on the master).

How do I use SSH credentials in Jenkins?

Add SSH Key inside JenkinsIn the dropdown, select 'SSH username with private key' and then give a name for it. Copy the private key from the Jenkins server. Now you can clone any git repo in this Jenkins instance. You do not need to provide the credentials while configuring the job in Jenkins.

What is publish over SSH?

Use SSH during a buildThis plugin includes a builder which enables the use of the publisher during the build process. This means that you can send newly created packages to a remote server and install them, start and stop services that the build may depend on and many other use cases.

Where do I put SSH keys in Jenkins?

Add SSH Key inside Jenkins Now go to Credentials from left pane inside Jenkins console and then click global: Then Go to add new credentials. Kind dropdown, select 'SSH username with private key'.


3 Answers

Looks like you're using keyfile authentication, so you'll get this error from Jenkins if you haven't set the permissions correctly on your .ssh folder and/or ~/.ssh/authorized_keys file.

  • the .ssh folder should have drwx------ permissions (read/write/execute owner only)
  • the authorized_keys file should have -rw------- permissions (read/write owner only)

To fix it:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
like image 144
inanutshellus Avatar answered Nov 09 '22 13:11

inanutshellus


I ran into the same issue today and it turned out i was accidentally supplying the path to the public key instead of the private one.

So the "path to key" should be something like

.ssh/id_rsa

instead of

.ssh/id_rsa.pub
like image 31
Rinda Avatar answered Nov 09 '22 14:11

Rinda


Because your linux login need password, the answer is :

 1. Passphrase: your passphrase
 2. path to key: your private key path
 3. key : blank
 4. Disable exec : un-check

SSH Servers

1. Name: [email protected]
 2. hostname: remotehost.com
 3. Username: remote_user
 4. Remote Directory: empty

Advanced --

5. check the box "use passsword authentication, or use a different key"
    `important`

 6. Passphrase / Password: your linux login password`important`

 7. path to key: blank

 8. key:blank

 9. port: 22

 10. Timeout(ms): 300000

'Test Configuration' success

like image 37
atmosphereqq Avatar answered Nov 09 '22 13:11

atmosphereqq