Jenkins Node creation

Hi, im new to jenkins and would like to know what are the different ways to create nodes in jenkins, I knew about 2 ways:

  1. Using ssh : copying the ssh-keygen public key to agent node and connecting to the node via username and ssh private key.
  2. Using command: Creating agent.jar on agent node and connecting to the node via command (ssh ubuntu@ip-address ‘java -jar agent.jar’

both ways are not working for me. Is there any other way to create a node?

using ssh is the standard way. If this doesn’t work then you have an error in your setup. Maybe you can post a screenshot of your configuration so we can check if the setup is correct.
Setting up ssh is not so complex.
You create a keypair with ssh-keygen, save the private key as credential in Jenkins and add the public key in the users authorized_keys. Then select the proper server authentication method and then it should work.

Save the private key as credential in jenkins means :
public key location: /var/lib/jenkins/.ssh/
or /home/ubuntu/.ssh/
i have used home/ubuntu/.ssh/

should i move them to jenkins or create a new keypair and save them in jenkins?
or should i move the Known_hosts to jenkins location : /var/lib/jenkins/.ssh/known_hosts ?

After creation of a private public key with ssh-keygen you get 2 files:
id_rsa and (the names may be different when you choose another algorithm for the key)
Put the content of into the users authorized_keys file on the machine you want to attach to Jenkins

to save the credential in Jenkins go to

  • Manage Jenkins → Manage Credentials
  • Click on (global) Domain
  • Click Add Credential
  • Select SSH Username with private key
  • Choose an ID that allows you to recognize the credential easily if empty it will generate a UUID
  • Add the username to use
  • Check Enter directly
  • Click Add
  • Copy the content if the file id_rsa into the field.
  • Enter the passphrase for the key (if there is one)
  • save

  • Go to your agent configure page
  • Launch method should be Launch Agents via SSH
  • Choose the credential you just added
  • in Host key verification strategy choose manually trusted key verification strategy

Now you should be able to connect.

Its showing the same error.

should i give a password to agent server and change the password for ubuntu:

sudo passwd ubuntu:
new password:

sudo vim /etc/ssh/sshd_config

change the passwordauthentication no to yes?

this will work ??

You can also authenticate with username and password. For this create a credential of kind Username with password and choose this in the agents config. And you need to enable password authentication as you mentioned.
Other than that your problem is not related to Jenkins but it might be related to settings in the ssh daemon of the target machines. With an ssh key you should not need a password for the user.
Try to connect from command line with the private key and see if it works.

I had a doubt:

i have created jenkins server and agent server and installed java in both the servers,

Now to create jenkins node creation in manage jenkins, do we need to create ssh-keygen on jenkins server or agent server?