Please switch user as jenkins in master node:
sudo su - jenkins 2.Now generate the key using ssh-keygen ssh-keygen
Copy the cat id_rsa to your jenkiens credentials
Copy the cat id_rsa.pub to your agent node ubuntu@agent:~/.ssh$ vi authorized_keys
now test the connection
Hope this weil work for you