xxxxxxxxxx
$ pbcopy < ~/.ssh/id_ed25519.pub
# Copies the contents of the id_ed25519.pub file to your clipboard
xxxxxxxxxx
cat > /path/to/file.txt
after this the terminal waits user input, so you can paste from your clipboard:
Ctrl + Shift + v
Then press Enter
And exit cat with Ctrl + c