Add your SSH key to your Ubuntu server

Using SSH keys is the recommended way of accessing your server, as far as security goes.

Therefore, use the following command in your terminal to add your key to the remote host:

cat ~/.ssh/id_rsa.pub | ssh username@remote_host "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Source: