×

This article covers how to create a new SSH key pair and set up an SSH key-based authentication. You can set up same key to multiple remote hosts on CentOS system. Also, you will learn how to disable SSH password authentication.

SSH, or secure shell, is an encrypted protocol used to administer and communicate with servers. When working with a CentOS server, chances are, you will spend most of your time in a terminal session connected to your server through SSH.

SSH keys are typically configured in an authorized_keys file in . ssh subdirectory in the user's home directory. Typically a system administrator would first create a key using ssh-keygen and then install it as an authorized key on a server using the ssh-copy-id tool.

The public key should be stored in the ~/. ssh/authorized_keys file on the server.


To Create the RSA Key Pair:

1. Execute the command below to create a key pair on the client machine (usually your computer):

$ ssh-keygen

2. Press ENTER to save the key pair into the .ssh/ subdirectory in your home directory, or specify an alternate path.


Best Practices to improve SSH Key Security:

  • Discover all SSH Keys and Bring Under Active Management.
  • Ensure SSH Keys Are Associated With a Single Individual.
  • Enforce Minimal Levels of User Rights Through PoLP.
  • Stay Attentive to SSH Key Rotation.
  • Eliminate Hardcoded SSH Keys.
  • Audit All Privileged Session Activity.



This article covers how to create a user with sudo privileges. You can now log in to your CentOS server with this user account and use sudo to run administrative commands.

Performing server administration as a non-root user is a best practice.

For security, your first task when deploying a CentOS instance is to create a non-root user with sudo access.


How to Add a New User Account on CentOS Linux System ?

1. To Create a new user account with the adduser command:

# adduser example_user

2. Set a strong password for the new user (new_user) with passwd.

# passwd new_user



This article covers how we can add and maintain swap space in the ubuntu system. Swap space can take the form of either a dedicated swap partition or a swap file. Typically, when running Ubuntu on a virtual machine, a swap partition is not present, and the only option is to create a swap file.


To Adjust the Swappiness Value:

Swappiness is a Linux kernel property that defines how often the system will use the swap space. It can have a value between 0 and 100. A low value will make the kernel to try to avoid swapping whenever possible, while a higher value will make the kernel to use the swap space more aggressively.

On Ubuntu, the default swappiness value is set to 60. You can check the current value by typing the following command:

$ cat /proc/sys/vm/swappiness


To Remove a Swap File:

1. First, deactivate the swap space:

$ sudo swapoff -v /swapfile

2. Next, remove the swap file entry /swapfile swap swap defaults 0 0 from the /etc/fstab file.

3. Finally, remove the actual swapfile file using the rm command:

$ sudo rm /swapfile




More Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on IbmiMedia.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com