Run SSH Agent using a command on Master

Issue

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.

Environment

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

Resolution

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? Submit a request

1 Comments

  • 0
    Avatar
    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?

Please sign in to leave a comment.