miko7358
miko7358

Reputation: 1101

Vagrant : Create new user and force the use of ssh keys for accessing the server

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 :

So I was supposed to be able to log in but I always have this message : Permission denied (publickey).

I tried :

Upvotes: 0

Views: 486

Answers (1)

miko7358
miko7358

Reputation: 1101

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:

error: Could not load host key: /etc/ssh/ssh_host_ed25519_key

So I checked the sshd_config file and there was this line (I didn't add myself):

# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key

So I simply commented the last line and I could access my server with my public key.

Upvotes: 0

Related Questions