- On client, navigate to the ssh folder.
cd ~/.ssh
- Generate a key pair, public and private. Make sure to specify a unique name to allow ids for connecting to multiple devices.
ssh-keygen
- Add the key to the ssh agent, so it is used when attempting to connect.
ssh-add ~/.ssh/key-file-name
- Copy to the target server.
ssh-copy-id username@remote-host
- Verify by trying to connect to the remote host.
ssh user@remote-host -i ~/.ssh/key-file-name
# List keys known by ssh-agent
ssh-add -l