Setting up public key authentication
In this recipe, you will see how to set up secure public key authentication.
Getting ready
You might need root privileges for certain tasks.
How to do it...
Follow these steps to set up public key authentication:
- Add a new user. You can skip this step if you have already created a user:
$sudo adduser john
- Log in as
john
and change to thehome
directory withcd ~/
: - Create a
.ssh
directory if it doesn't already exist:$ mkdir .ssh
- Create a file named
authorized_keys
under the.ssh
directory:$ touch .ssh/authorized_keys
- Set permissions on the
.ssh
directory to700
:$chmod 700 .ssh
- Set permissions for
authorized_keys
to600
:$ chmod 600 .ssh/authorized_keys
- Generate public key pair on your local system with the following ...
Get Ubuntu Server Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.