Use SSH to Connect to a Remote Server in Ubuntu
Login to your server
ssh remote_username@remote_host -p port
Enter the following into the command line to create ssh key
ssh-keygen -t rsa
Your keys will be created at ~/.ssh/id_rsa.pub and ~/.ssh/id_rsa.
id_rsa file is readable and writable only to the owner. This is how it should be to keep it secret.
id_rsa.pub file, however, can be shared and has permissions appropriate for this activity.
touch authorized_keys chmod 600 authorized_keys cat id_rsa.pub >> authorized_keys
save id_rsa to local and configure your local .ssh config file, then you are ready to go.
Host server HostName remote_host User username Port server_port IdentityFile where_id_rsa_place