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 :
$ssh-keygen
public key location: /var/lib/jenkins/.ssh/id_rsa.pub
or /home/ubuntu/.ssh/id_rsa.pub
i have used home/ubuntu/.ssh/id_rsa.pub
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 id_rsa.pub (the names may be different when you choose another algorithm for the key)
Put the content of id_rsa.pub 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)
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.