Generate SSH keys

ssh-keygen -C [email protected]

Authorize public key at remote server

ssh-copy-id user@host

On Mac OSX, ssh-copy-id should be installed first.

brew install ssh-copy-id

Generate PEM

ssh-keygen -f ~/.ssh/id_rsa -e -m pem > ~/.ssh/id_rsa.pem

Copy file by base64

On remote session, run base64 < myfile and copy the output.

On local terminal, run base64 -d > myfile, paste the content and press ctrl+D.