Run SSH Agent using a command on Master


I tested several methods to connect an Agent to a Master but none of those works
I would like to use native ssh client to connect to my Agents.
SSH plugin randomly disconnects.


  • Jenkins
  • Jenkins LTS
  • CloudBees Jenkins Enterprise (CJE)
  • SSH Slave plugin
  • CloudBees SSH Agents


You could launch the agent with a command in the master and use command line SSH to do that. It uses a SSH native command to make the tunnel. It could be a way to move forward while you diagnose the main issue.

Use this command to launch the Agent, you have to replace words in capitals by your own values

ssh -i PATH_TO_KEY_WITHOUT_PASSPHRASE USER@HOST "cd AGENT_HOME_DIR && curl -O http://JENKINS_URL/jnlpJars/slave.jar && java -jar slave.jar"

You need a RSA key without passphrase and need to add this key as authorised key on each Agent (~/.ssh/authorized_keys)

ssh-keygen -t rsa -f $HOME/.ssh/test_rsa

Use this command to add the key to authorized keys in Agent, so that you can access the Agent from Master using that key

ssh-copy-id -i$HOME/.ssh/test_rsa USER@HOST

Have more questions?


  • 0
    John Seiberling

    I see that these launch commands have been running on the master for days. It appears they are persistent. Is this the expected behavior or are these threads lingering zombies that should not be present?

  • 0
    Steven Christenson

    I strongly suggest that if using the manual launch method, that additional commands be tossed into the mix.

    E.g. "env" so you can see what the environment is, "java --version" to be sure the default java is what is expected...

    And I know John's question is old, but yes, if you use manual launch, it spawns another process that persists for the duration of the connection.

    We have python based launch mechanisms for our persistent docker slaves (I mean agents :-) that linger.

Please sign in to leave a comment.