The first step is to generate the key using the command ssh-keygen -t rsa which prompt to enter the key file name, I typed ~/.ssh/id_rsa and to enter a passphrase (remember if you enter it you will be asked for it every time you want connect to the remote machine)
now in the folder ~/.ssh there are 2 files:
- id_rsa, the private key
- id_rsa.pub, the public key
The second step is to copy the public key to the remote machine, to do that use the command ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote_machine
This is all.
In my case I had an old previous key with a differente name, I deleted it and so the ssh wasn't able to find my key. I discovered becouse every time I tryed to connect to the remote machine with ssh user@remote_machine my password (not my passphrase) was required. So I modified the /etc/ssh/ssh-config file
Host *IdentityFile ~/.ssh/id_rsa #the private key locationto use multiple private keys to connect to different servers check http://stackoverflow.com/questions/2419566/best-way-to-use-multiple-ssh-private-keys-on-one-client