Single command to generate & copy public SSH key
I always forget how to run this simple command, so I’ll just leave it here so you can use it and I won’t forget it.
Regular Generate & Copy public SSH keys
$ ssh-keygen; ssh-copy-id user@host; ssh user@host
Just change the user@host and you’re on your way.
Custom Port
If your host has a different SSH access port, then it get’s a little trickier, but still works:
$ ssh-keygen; ssh-copy-id ‘-p XXXX -i ~/.ssh/id_rsa.pub username@host’; ssh user@host
Note that the ssh-copy-id call is a little different, and execute in quotes (if you copy & paste, the single-quotes can cause error, so replace them with normal single-quotes).
Source: Simple, Custom Port

