EDIT: Putting exactly what was done
I need to SSH localhost without password, the usual way of doing it (with public keys) do not work.
user@PC:~$ rm
Do the following steps
ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
Use the default file and empty passphrase (Simply press enter in the next 2 steps)
# start the ssh-agent in the background
eval "$(ssh-agent -s)"
# Agent pid 59566
ssh-add
Copy the contents of ~/.ssh/id_rsa.pub to ~/.ssh/authorized_keys
Ensure following are the permissions
ls -l .ssh/
total 20
-rw-r--r--. 1 swati swati 399 May 5 14:53 authorized_keys
-rw-r--r--. 1 swati swati 761 Jan 12 15:59 config
-rw-------. 1 swati swati 1671 Jan 12 15:44 id_rsa
-rw-r--r--. 1 swati swati 399 Jan 12 15:44 id_rsa.pub
-rw-r--r--. 1 swati swati 410 Jan 12 15:46 known_hosts
Also, ensure the permissions for .ssh directory are. This is also important
drwx------. 2 swati swati 4096 May 5 14:56 .ssh
as the accepted answer do, if you encount a problem of
Agent admitted failure to sign using the key.
you need to
ssh-add
Have discovered the problem.
Running the server with debuging:
$sshd -Dd
I found it was not able to read the auth_key
$chmod 750 $HOME
Fixed it.
I fixed my problem setting the AllowUsers on sshd_config file.
Running the server with debuging:
$sshd -Dd
I found it was not allowed the my user
$sudo vi /etc/ssh/sshd_config
Add a row with after #Authentication:
AllowUsers myUser
Another possible answer: the authorized_keys file may exist and be readable. But if it is group- or world-writable, it will still prompt for the password. The answer to THAT problem is
chmod og-wx ~/.ssh/authorized_keys
On Centos 7
SOLUTION
1 create rsa key
2 vim /etc/ssh/ssh_config
3
# IdentityFile ~/.ssh/identity
uncoment this line > IdentityFile ~/.ssh/id_rsa
# IdentityFile ~/.ssh/id_dsa
# IdentityFile ~/.ssh/id_ecdsa
Note *I did this after copying the key and some of the other answers before this one. But I am pretty sure this is all you have to do but if not I would append the rsa key to authorized_keys and also run the
ssh-copy-id to username@localhost