Search code examples
jenkinsjenkins-pluginsssh-keys

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.


Solution

  • 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