To install the OpenSSH server application on your Ubuntu server system:
sudo apt-get install openssh-server
Backup original configuration file
sudo cp / etc/ssh/sshd_config / etc/ssh/sshd_config.original
sudo chmod a-w / etc/ssh/sshd_config.original
Generate SSH keys
During the process you will be prompted for a password. Simply hit Enter when prompted to create the key.
ssh-keygen -t rsa
By default the public key is saved in the file ~/.ssh/id_rsa.pub, while ~/.ssh/id_rsa is the private key.
Copy id_rsa.pub file to the remote host
Copy the id_rsa.pub file to the remote host and append it to ~/.ssh/authorized_keys by entering:
chmod 600 .ssh/authorized_keys
For more please visit ubuntu.