Ajout Key SSh

#!/bin/bash

if [ "$#" -ne 2 ]; then

   echo "Usage: $0 <username> <remote_host>"

   exit 1

fi

username="$1"

remote_host="$2"

### COPY

If ssh-copy-id "$username@$remote_host" 2>/dev/null; then

   cat ~/.ssh/id_rsa.pub | ssh $username@$remote_host 'mkdir -p ~/.ssh && cat  >> ~/.ssh/authorized_keys'

   echo " COPY OK to host : $remote_host"

   echo "you can Test with   >>>   ssh $username@remote_host"

else

   echo "Failed to copy public key on host : $remote_host "

   exit 1

fi