Selecting terminal output with the mouse is slow and always grabs one character too many.
Pipe it into pbcopy. It takes standard input and places it on the pasteboard, which is what the Mac calls the clipboard.
cat ~/.ssh/id_ed25519.pub | pbcopy
The reverse is pbpaste. It writes the pasteboard contents to standard output, so you can feed copied text into another command.
pbpaste | sort -u | pbcopy
That line takes a copied list, removes duplicates and puts the result back on the clipboard. No editor needed.
The man page has two details worth knowing. Input is saved as plain text unless it starts with an EPS or RTF header. And if the pasteboard holds none of the types pbpaste looks for, it prints nothing, so a copied image gives you an empty result and not an error.
Once you use these two, you start seeing them everywhere: copy the output of a build, paste a command from a note, send a log line to a chat. The clipboard becomes just another stream, which is how shell people like it.
Further reading: pbcopy.1 man page, On this site: pbcopy puts the output of any command on your Mac clipboard
Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more