'Publish over ssh error jenkins [Failed to connect session for config [test12]. Message [Auth fail]]

Installed new Jenkins, want to use Publish over SSH plugin. publish over SSH plugin version: 1.24 getting below error.

[Failed to connect session for config [test12]. Message [Auth fail]]

Also, tried the solution given here https://issues.jenkins.io/browse/JENKINS-57495?focusedCommentId=372383&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-372383

Went to my EC2 server.

sudo su jenkins.

under /var/lib/jenkins/.ssh.

created keys with the following command also with passphrase.

ssh-keygen -t rsa -b 4096 -m PEM.

after that copied the id_rsa.pub to the target host.

did the ssh -i id_rsa ubuntu@serverip it works from the command-line.
But is broken from the UI



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source