Trying to deploy code to new server with ssh, getting below error when i test the connection to remote server.
jenkins.plugins.publish_over.BapPublisherException: Failed to add SSH key. Message [invalid privatekey: [B@2d272efe]
In jennkins console log, i see below error:
SSH: Connecting from host [jenkins-server]
SSH: Connecting with configuration [remote server name] ...
SSH: Creating session: username [remote user], hostname [remote server], port [22]
SSH: Connecting session ...
ERROR: Exception when publishing, exception message [Failed to connect and initialize SSH connection. Message: [Failed to connect session for config [remote server name]. Message [Auth fail]]]
[Pipeline] sshPublisher
SSH: Current build result is [FAILURE], not going to run.
copied jenkins pub key to remote server.
Anybody can give me steps on how and what to do to deploy code to new server?
Jenkins is able to deploy to other already added existing servers.
Hi @poddingue
Yes, i can login thro ssh from Jenkins to target machine.
manually copied public key from jenkins to target machine.
I will try ssh-copy-id command to check if that helps.
Thank you so much.
I’ve faced a similar issue. Currently, the situation is that I can connect to the remote server through SSH on the Jenkins server, but I can’t establish a connection through the SSH plugin’s UI in Jenkins (I’ve already uploaded the private key for the remote server to Credentials).
cat /var/logo/auth.log
Jan 24 20:59:37 ip-x-x-x-xsshd[47367]: Disconnected from authenticating user ssh-user xxxx port 46478 [preauth]
Jan 24 21:02:40 ip-xxx sshd[47385]: Invalid user jenkins from xxx port 46488
Jan 24 21:02:40 ip-xxxx sshd[47385]: error: Received disconnect from xxxx port 46488:3: com.jcraft.jsch.JSchException: Auth fail [preauth]
I am also experiencing similar error;
Jenkins OS: RHEL-9.4; Jenkins-2.453.2, java-openjdk -21.0.3, Publish Over SSHVersion1.25,
SSH session tried with RHEL-9 & RHEL-7.
from command line, password less connections works fine; but with Jenkins Console, the test is failing. RSA key created with 4096 & PEM option.
"Error:
Failed to connect or change directory.
jenkins.plugins.publish_over.BapPublisherException: Failed to add SSH key. Message [invalid privatekey]
Figured out the mistake I was doing.
It worked; Verified with 2048 bit RSA key & 256 bit ed25519 key (that is the default bit in RHEL-9); with OpenJDK -11 & 21.