SSH key-based login lets you connect to a remote server without typing the account password each time. It is also the preferred approach for automation, scripts and secure administration.
Create an SSH key
ssh-keygen -t ed25519
Use a passphrase unless the key is specifically for controlled automation.
Copy the public key to the server
ssh-copy-id user@server
Test the login
ssh user@server
Where the key is stored
~/.ssh/id_ed25519 # private key
~/.ssh/id_ed25519.pub # public key
Keep the private key private. Copy only the .pub public key to remote systems.