Worth adding the piece that makes key authentication genuinely pleasant rather than merely correct: the client's config file.
A block in ~/.ssh/config giving a host an alias, a user, a port and a key means your script says ssh myserver and nothing else. No flags, no paths, no repetition, and changing the server means editing one file rather than every script.
Most people discover this years after they start using ssh and immediately wish they had not.