Login with ssh key and disable user password login
In this post, I'll tell you, how to create new user in Ubuntu 14.04 and how you disable user password login.
New user
Create new user, in my e.g. it's example-user
. Set strong password, and fill fields.
$ sudo adduser example-user
SSH key login
Now you're created new user. In second step, we have to generate new ssh key (if you don't already had it).
$ ssh-keygen
And use default value for:
Generating public/private rsa key pair.
Enter file in which to save the key (~/.ssh/id_rsa):
Next we need to copy our ssh key into example-user's authorizies keys file (~/.ssh/authorized_keys).
$ ssh-copy-id example-user@localhost
If you got next lines, you're permit login to example-user by ssh key.
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'example-user@localhost'"
and check to make sure that only the key(s) you wanted were added.
Disable user password login
It mean that, you're not longer need password to login example-user
. So if we don't any more need password to login our new user, we could disable password login to that user.
$ sudo usermod -L example-user