Corinne Kubler
Corinne Kubler

Reputation: 2092

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.

Upvotes: 10

Views: 82151

Answers (13)

vishun
vishun

Reputation: 97

I have the same problem,I am on windows, the solution:

  • open the openssh debug model, no can see the error detail, detail click
    • Stop the sshd service
    • Type 'sshd -d' in PowerShell
  • no if you connect again ,you can see the error detail, my error is
    userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]
    
  • we can add PubkeyAcceptedKeyTypes=+ssh-rsa in server sshd_config file, detail click
  • now test success, if still has error like Failed to connect SFTP channel and debug is
    debug1: subsystem: cannot stat sftp-server.exe: No such file or directory
    
    this because the openssh no in windows system path. detail click

Upvotes: 0

KoKon
KoKon

Reputation: 1

If you use RSA key, and see string like this in your private key:

    -----BEGIN RSA PRIVATE KEY-----
***************************************

-----END RSA PRIVATE KEY-----

You need edit config file sshd on remote machine:

sudo vim /etc/ssh/sshd_config

add in this file stoke:

HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa

Upvotes: 0

Cesar Bielich
Cesar Bielich

Reputation: 4945

I was having the same exact issue today and thought I would share what worked for me

Normally when I would SSH into my ec2 instance AWS likes the username to be

ubuntu@[ip address/url]

Jenkins likes it to be just the username so remove the rest

ubuntu

Upvotes: 0

artemiuz
artemiuz

Reputation: 464

Just copy jenkins-user's id_rsa.pub to the end of ~/.ssh/authorized_keys on remote host.

Upvotes: 0

Karthik
Karthik

Reputation: 65

Sometimes the SSH connection would fail, if the destination server doesnt have enough disk space to perform PUT operation

{ERROR: Exception when publishing, exception message [Failure]}

Make sure to verify the destination server has enough disk space.

In case of Linux, you can use 'df -kh /directoryname' to check the disk space

Upvotes: 0

lalith
lalith

Reputation: 1

Don't do any ssh-keygen. Just enter the pem key details under key field, Add SSH server details: Name, Hostname and Username as ec2-user. Click test connection and it works.

Upvotes: 0

Supun Dharmarathne
Supun Dharmarathne

Reputation: 1148

Try restarting ssh of remote server

        /etc/init.d/sshd restart

Upvotes: 0

atmosphereqq
atmosphereqq

Reputation: 31

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

Upvotes: 3

inanutshellus
inanutshellus

Reputation: 10001

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

Upvotes: 20

Rinda
Rinda

Reputation: 326

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

Upvotes: 6

Cherry Yap
Cherry Yap

Reputation: 21

I am facing same issue , the following steps work for me:- ( i am using jenkins 1.57)

  1. Go to http:///jenkins/manage
    1. Configure System
    2. Browse to Publish over SSH section
      • Passphrase: blank
      • path to key: blank
      • key : blank
      • Disable exec : un-check
      • SSH Servers -- Name: [email protected] -- hostname: remotehost.com -- Username: remote_user -- Remote Directory: empty -- Advanced -- check the box "use passsword authentication, or use a different key" -- port: 22 -- Timeout(ms): 300000 -- 'Test Configuration'

success

Upvotes: 1

Joey Coleman
Joey Coleman

Reputation: 489

Check that the public key is in the .ssh/authorized_keys file on the target server, even if the target server is the same as the jenkins server. I had what is probably the same problem, and it turned out that I needed this, even though ssh localhost worked fine.

(Addendum: also check that the jenkins server has the target server in its .ssh/known_hosts file, as that can affect this as well.)

Upvotes: 2

AltF4_
AltF4_

Reputation: 2460

I think as it says this is a authentication issue:

Use password authentication, or use a different key Selecting this option will produce 3 more configuration boxes that mirror the options available for the Jenkins SSH Key.

Passphrase / Password If either Path to key or Key are configured then this is the passphrase to use with the encrypted key. If no key is configured then this is the password that will be used for password authentication.

Path to key See description above.

Key See description above.

Disable exec This option will remove the ability to execute commands using this configuration.

LINK HERE

Upvotes: 1

Related Questions