Generate ssh keys of your current system

$ ssh-keygen -t rsa

Install openssh if not already installed on your system. On arch linux you can install it as follow, for other distribution follow distribution instructions to install openssh

$ sudo pacman -S openssh

If you already have created ssh keys and now created new one and now seeing this message “sign_and_send_pubkey: signing failed: agent refused operation”.
You need to add ssh key to your machine.

$ ssh-add

check if ~/.ssh directory is already created on server, if not created already then login to server using ssh and do following

$ mkdir  ~/.ssh
$ chmod 700 ~/.ssh/ 

Now go back to your machine and upload your generated public ssh key to server

$ cat ~/.ssh/ | ssh user@server_ip-or-server-name 'cat >> .ssh/authorized_keys'

login by username from your machine

$ ssh user@server_ip-or-server-name

You may need to set permission of authorized_keys file to 600 on server, to do that ssh login into server and set permissions as follow

$ chmod 600~/.ssh/authorized_keys 

enjoy folks 🙂