In your case "Server" and "Client" are that same computer.
Client side settings
Generate SSH keys pair.
mkdir ~/.ssh
cd ~/.ssh && ssh-keygen -b 2048 -t rsa -C "My Comment for key" -t "access_key"
Detailed information about ssh-keygen options you can read in man page:
man ssh-keygen
After that you can find two files access_key and access_key.pub in ~/.ssh/
Create file with name "config" in your ~/.ssh directory.
This file allow you to set up different settings for each host you need to connect.
Here is simple content of this file
Host my.remote-host.com
User remoteusername
Identityfile ~/.ssh/access_key
my.remote-host.com - target host to connect to (localhost)
remoteusername - login name of user on remote machine
Identityfile - path to you private key
Server side settings
How to enable "PublickKey" authentication:
sudo nano /etc/ssh/sshd_config
Uncomment next lines:
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
RSAAuthentication - enable RSA keys support
PubkeyAuthentication - enable authentication by public keys
AuthorizedKeysFile - path to file that contain public keys
Restart your ssh server
sudo service sshd restart
Create directory and set correct permissions
mkdir ~/.ssh
sudo chmod 700 ~/.ssh
Create file for public keys and set correct permissions
touch ~/.ssh/authorized_keys
sudo chmod 600 ~/.ssh/authorized_keys
Put your public key (access_key.pub) into ~/.ssh/authorized_keys
You should use only one line per each key. Example:
ssh-dss AAAAB3NzaC1kc3MAAAbC2kVOJpcnfu7UqKV44uZ/khiP9K7F...aoSe MyComment
How to completely disable password authentication
sudo nano /etc/ssh/sshd_config
Change PasswordAuthentication from "yes" to "no"
Restart sshd server
sudo service sshd restart