Getting the public key onto the server
For key-based auth to work, your public key needs to be in the server's ~/.ssh/authorized_keys file (one key per line). Three ways to do that — easy, manual, and direct edit.
The easy way — ssh-copy-id
If ssh-copy-id is available (Linux yes, macOS no by default but brew install ssh-copy-id), it handles everything: connects via password, creates ~/.ssh/ if needed, appends your key, sets permissions correctly. One command, done.
The manual way
If ssh-copy-id isn't around, pipe your public key over an SSH session that creates the directory and appends. Or paste it by hand into the server's authorized_keys.
Permissions matter — silently
SSH refuses to use authorized_keys (or even the .ssh directory) if permissions are too loose. The failure mode is silent — auth just falls back to password without telling you why. Whenever key auth mysteriously stops working, check permissions first.