If you want to use public key authentication over SSH in your server you can just change localhost with your servers IP address.
First you need to install openssh-server.
Make user and test your ssh works.
Make public and private keys.
You can leave these questions empty if you don’t want to change the directory where keys are saved and if you dont’ want to use passphrase when you take ssh connection.
Copy public key to user and test it works
Make three new users
Let’s make public key copying to new users in loop.
Let’s make shell script that connects to all users and makes whoami so we can confirm that users and ssh connection is working.
Run shell script
Now you are successfully using public key authentication over SSH with four different users.