Nested loops

What do I have:

  • list of users’ names on my server
  • list of developers’ names OR list of developers’ ssh keys

What do I want:

For every developer in my project I’d like to add his ssh key to authorized key of each user on server so that all developers can log in via SSH without providing password.

How did I try to solve that:

  • Download from GitHub keys for every developer and store it in some location → read from this location the content of file and then put it into each user authorized keys
  • Loop over each developer key and then loop over each user to add this key to its authorized_keys

How was the result:
In the first case I don’t know how to read from remote server all downloaded files and then loop through all users to add there downloaded keys.
In the second case I don’t know how to do nested loop with files and accounts names.

What do I need:
Has anyone do that before? What is the possible solution? How can I make nested loop (actually nest modules in some way).