ubuntu copy ssh key code example

Example 1: how to copy contents of ssh key into clipboard

pbcopy < ~/.ssh/id_rsa.pub

Example 2: copy my ssh key

clip < ~/.ssh/id_rsa.pub

Example 3: copy ssh keys

pbcopy < ~/.ssh/id_rsa.pub

Example 4: how to copy ssh key

ssh-copy-id -i ~/.ssh/mykey user@host

Example 5: ubuntu create a ssh key

cat ~/.ssh/id_rsa.pub | ssh username@remote_host "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod -R go= ~/.ssh && cat >> ~/.ssh/authorized_keys"