@Mohamed Khalifa BOUTAHIR
Few things you should check before you try to register/install agents via Ambari UI.
0). Create password less ssh keys (with Emopty pass phrase)
1). What is the permission of the following files (should be 600) ?
# ls -l ~/.ssh/id*
-rw-------. 1 root root 1679 May 22 2018 /root/.ssh/id_rsa
-rw-------. 1 root root 406 May 22 2018 /root/.ssh/id_rsa.pub
2). In order to perfectly copy the SSH Keys to other hosts
# ssh-copy-id -i ~/.ssh/id_rsa.pub hdp-master1
# ssh-copy-id -i ~/.ssh/id_rsa.pub hdp-master2
# ssh-copy-id -i ~/.ssh/id_rsa.pub hdp-slave1
# ssh-copy-id -i ~/.ssh/id_rsa.pub hdp-slave2
# ssh-copy-id -i ~/.ssh/id_rsa.pub hdp-slave3
3). Onece above is done then try to manually connect to those hosts to see if you are able to do passwordless on your own own not?
# ssh root@hdp-master2
# ssh root@hdp-slave-1
Few other things to check:
4). Are you running Ambari Agents as non root user?
5). Make sure that every Node in the cluster has correct entries inside the "/etc/hosts" file (mostly it will be identical entries on all hosts) so that every node in the cluster can identify each other using theior FQDN. So please verify the following commands on couple of cluster nodes to see if they are showing correct results?
# hostname -f
6). Now proceed with the Ambari UI to setup the cluster.