We use cookies to improve our services and provide a better experience. By continuing to use this site, you agree with our Cookies Policy.

Tutorials

More than 400 step-by-step articles to guide you through online project development.
HomeTutorialsOperating SystemsLinuxAdministration

Introduction to SSH Keys

OpenVZ VPS

SSH keys provide a more secure way to access your server than logging in as root. The root password can be hacked by brute forcing your server, while SSH keys are very safe and almost impossible to hack.
There are two parts of SSH keys – public and private. Click here if you’d like to learn how to create SSH keys.
The public key is intended to be added to the server and the private key must be kept privately – it will be used for logging to the server.

Follow This Tutorial to Add SSH Keys

For example, let’s use PuTTY.
putty

useradd new_user
passwd new_user

com

You have already created a user in your server and have the password set for this user. Actually the password does not really matter, because you will prohibit permission to log in with password later.

mkdir /home/new_user/.ssh/
touch /home/new_user/.ssh/authorized_keys | chmod 700 /home/new_user/.ssh/ | chmod 600 /home/new_user/.ssh/authorized_keys
nano /home/new_user/.ssh/authorized_keys

fuu

After the key for the new_user is added successfully, configure SSH service so that it listens for SSH keys and permits login with password. To do that you have to change the value to no next to PermitRootLogin and uncomment this section (remove #):

uuuu

Before you are done, just restart SSH service and log in to the server as new_user :

jjjj

NOTE: if you want new_user to run all commands , add new_user to the wheel group and let this group act as root without password:

useradd –G wheel new_user

Nano /etc/sudoers and uncomment the line:

## Same thing without a password
%wheel ALL=(ALL) NOPASSWD: ALL

kkkkkk

Congratulations! Your server is now secured and can be accessible only with your SSH key.

Ubuntu VPS
Rate this Tutorial:
No Comments

Other (3)

Popular Keywords