Bamboo agent ssh timed out error with the server its logging into
Asked by tabrez ahmad:

**Bamboo agent ssh timed out error with the server where its trying to run a script, few lines of the script is executed and then the connection is timed out.**

Error Details:

error 13-Apr-2022 11:33:36 net.schmizz.sshj.connection.ConnectionException: Timeout expired  
error 13-Apr-2022 11:33:36 at net.schmizz.sshj.connection.ConnectionException$1.chain(ConnectionException.java:32)  
error 13-Apr-2022 11:33:36 at net.schmizz.sshj.connection.ConnectionException$1.chain(ConnectionException.java:26)  
error 13-Apr-2022 11:33:36 at net.schmizz.concurrent.Promise.retrieve(Promise.java:139)  
error 13-Apr-2022 11:33:36 at net.schmizz.concurrent.Event.await(Event.java:105)  
error 13-Apr-2022 11:33:36 at net.schmizz.sshj.connection.channel.AbstractChannel.join(AbstractChannel.java:280)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.plugins.scp.SshTask.getCommandResult(SshTask.java:222)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.plugins.scp.SshTask.execute(SshTask.java:132)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.task.TaskExecutorImpl.lambda$executeTasks$3(TaskExecutorImpl.java:323)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:256)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:323)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:116)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:73)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.executeBuildPhase(DefaultBuildAgent.java:184)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:156)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.lambda$waitAndPerformBuild$0(BuildAgentControllerImpl.java:130)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:118)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:124)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.lambda$start$0(DefaultBuildAgent.java:108)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41)  
error 13-Apr-2022 11:33:36 at java.lang.Thread.run(Unknown Source)  
error 13-Apr-2022 11:33:36 Caused by: java.util.concurrent.TimeoutException: Timeout expired  
error 13-Apr-2022 11:33:36 ... 21 more  
error 13-Apr-2022 11:33:36 Error occurred while running Task 'Deploy Code to Development Environment(2)' of type com.atlassian.bamboo.plugins.bamboo-scp-plugin:sshtask.  
error 13-Apr-2022 11:33:36 com.atlassian.bamboo.task.TaskException: SSH command failed  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.plugins.scp.SshTask.execute(SshTask.java:148)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.task.TaskExecutorImpl.lambda$executeTasks$3(TaskExecutorImpl.java:323)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:256)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:323)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:116)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:73)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.executeBuildPhase(DefaultBuildAgent.java:184)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:156)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.lambda$waitAndPerformBuild$0(BuildAgentControllerImpl.java:130)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:118)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:124)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.lambda$start$0(DefaultBuildAgent.java:108)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17)  
error 13-Apr-2022 11:33:36 at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41)  
error 13-Apr-2022 11:33:36 at java.lang.Thread.run(Unknown Source)


Answers:
author: Eduardo Alvarenga
body: Hello [@tabrez ahmad](/t5/user/viewprofilepage/user-id/4714421),

Can you run the same SSH connection from the Agent command line using the 'ssh' command?

If 'ssh' works, please open a support ticket on <https://support.atlassian.com/contact> as we'd be interested to debug the **net.schmizz.sshj** class.

Eduardo Alvarenga  
Atlassian Support APAC

comments: author: tabrez ahmad
body: Hi Eduardo,

We tried running the script on the server from our remote agent and it was successful and there was no SSH connection issue.

Thanks,

Tabrez


author: Charlie.Gunzelman
body: We're having the same issue with longer build jobs. Recently upgraded Bamboo from 8.0.4 to 9.1.0 and all of our most imporant builds are now failing even with SSH Keepalive set to 5 or 10 seconds on SSH Tasks.