"Path to key" doesn't work (Jenkins 2.414.2, Publish Over SSH 1.25)

Hello, everybody!

Jenkins 2.414.2, Plugin Publish Over SSH 1.25

I have 3 hosts :

  • Jenkins server
  • Build node (worker4.internal)
  • SSH server (green)

I’m trying to connect to SSH server during Post-build Actions in my Jenkins Job.
ssh-key placed at Jenkins server in /var/lib/jenkins/.ssh/id_rsa

If I place the key in the field “Key” (Dashboard > Manage Jenkins > System > SSH Servers > Advanced) - everting works fine. But when I set “Path to key” = “/var/lib/jenkins/.ssh/id_rsa” instead of pasting the key in the field “Key” job execution hangs at “Creating session”:

Console output:

...
+ whoami
jenkins-agent
+ hostname
worker4.internal
SSH: Connecting from host [worker4.internal]
SSH: Connecting with configuration [green] ...
SSH: Creating session: username [....], hostname [...], port [22]

<hangs at this place>

However “Test Configuration” Succeed as well as manual connecting in terminal from Jenkins Server host with “ssh -i /var/lib/jenkins/.ssh/id_rsa username@ssh_server_ip_address”

There is the same behavior when I set Credentials in my Jenkins Job > Post-build Actions > Send build artifacts over SSH > Credentials:
Pasting the key in the “Key” field - works
Setting “Path to key” - doesn’t work

The same “hang” when I set wrong path in the “Path to key” with the difference that I get connection error when trying to “Test Configuration”.

I’ve tried to place ssh-key at SSH Server (green) (at /home/jenkins-agent/.ssh/id_rsa), but it also hangs during Job execution. “Test Configuration” fails in this case, because it tests from Jenkins Server which doesn’t have this path.

As you can see in the following output, the shell command “ssh -i /home/jenkins-agent/.ssh/id_rsa username@ssh_server_ip_address” works correctly inside Jenkins job, but hangs in the next step when trying to connect the server with Publish Over SSH.

Console output:

...
+ whoami
jenkins-agent
+ hostname
worker4.internal
+ ssh -i /home/jenkins-agent/.ssh/id_rsa username@ssh_server_ip_address
Pseudo-terminal will not be allocated because stdin is not a terminal.

----------------------------------
     Welcome to green server
----------------------------------

To remove this message:
    rm -f /etc/update-motd.d/99-application

+ whoami
jenkins-agent
+ hostname
worker4.internal
SSH: Connecting from host [worker4.internal]
SSH: Connecting with configuration [green] ...
SSH: Creating session: username [...], hostname [...], port [22]

<hangs at this place>

Can anyone give an idea how to solve the problem?
Is it bug?