I try to enforce the use of SSH keys in order to access the server (I disabled password-based login).
I use "ubuntu/trusty64" for my vagrant. After the first boot of my VM, I created another user "gwendal" and I added him to the sudo group.
Here are the steps I followed :
[on my local computer] :
cd ~/.ssh
thenssh-keygen -t rsa -b 4096 -C [email protected] -f id_gwendal
and I finally copied the content ofid_gwendal.pub
[on my guest] : I switch from vagrant to gwendal user and I pasted the public key to
~/.ssh/authorized_keys
So I was supposed to be able to log in but I always have this message : Permission denied (publickey).
I tried :
ssh [email protected]
ssh -i ~/.ssh/id_gwendal -o "IdentitiesOnly yes" [email protected]
Thanks to the suggestion of Remus Rusanu I find the error.
When I check the last logs with
tail -500 /var/log/auth.log | grep 'sshd'
I noticed this:So I checked the sshd_config file and there was this line (I didn't add myself):
So I simply commented the last line and I could access my server with my public key.