Run a loop that will search for a file to thousand machine and know who owns the file

Run a loop that will search for a file to thousand machine and know who owns the file

[user@adm:~]$ for i in abc{01..02}
> do
> echo -n $i
> ssh $i "sudo find / -name .ssh -exec ls -l {} \;|grep id"
> done
abc01-rw-------. 1 root root 1675 Nov 10  2018 id_rsa
abc01-rw-------. 1 root root 1675 Nov 14  2018 id_rsa
abc01-rw-------. 1 root root 1675 Nov 20  2018 id_rsa
abc02-rw-------. 1 root root 1675 Nov 10  2018 id_rsa
abc02-rw-------. 1 root root 1675 Nov 11  2018 id_rsa

I was hoping for an output like this
user1
abc01-rw-------. 1 root root 1675 Nov 10  2018 id_rsa
user2
abc01-rw-------. 1 root root 1675 Nov 14  2018 id_rsa
user3
abc01-rw-------. 1 root root 1675 Nov 20  2018 id_rsa

user1
abc02-rw-------. 1 root root 1675 Nov 10  2018 id_rsa
user2
abc02-rw-------. 1 root root 1675 Nov 11  2018 id_rsa

[user@adm:~]$

Without knowing what operating system(s) those thousand machines are running and what the naming conventions on each of those thousand machines is for user's home directories, there isn't much chance that we can help you with a request like this. Knowing what shell you'll be using on the machine where you are running this script and on each of the thousand machines you'll be querying could also make a bg difference.

And, of course, this assumes that the directory named .ssh in each user's home directory is owned by that user (and not by root). One might also want to know if any user names on those thousand machines contains the string id .

names can be anyone. rhel is the OS.

In your sample in post #1 the file owner is root.
Perhaps you want to display the pathname?

for host in ...
do
  printf "%s \n" "$host"
  ssh -x "$host" 'sudo find / -maxdepth 6 -type f -path "*/.ssh/*id*" -exec ls {} \;'
done

Notes:
printf is better than echo -n .
Better limit the search depth, otherwise it can run for hours.

You could also try:

for host in ....
do
  printf "\nHost: %s\n" "$host"
ssh "$host" 2>/dev/null <<'EOF'
   ls -l $(awk -F: '{ print $6"/.ssh/id*" }' /etc/passwd) 2> /dev/null
EOF
done

It did not give me the owner.

comp2
/root/.ssh/id_rsa

comp1
/root/.ssh/id_rsa

Who, if not "root", could be the owner?