How to establish Server Setup with CentOS 7

Establish Server Setup with CentOS 7

One of the important and basic things you should know in Linux. i.e How to Create and Remove Users.

Using the system with default root account is not good, and it will end up in getting security problems.

So, it is always good to have a unprivileged user to carry out your task.

If you logged in as the root user, you can create new user anytime time by typing the following command.

STEP 1- Add the user 

# adduser moon  
# passwd moon

In case, if you like to remove the user , you can delete the user account without deleting the file by executing the user delete command perform as root.

# userdel moon

STEP 2 – Root Privileges

Now, we have a new user account with regular account privileges. However, we may sometimes need to perform some administrative tasks.

To avoid interruption add these privileges to our new user, we need to add the new user to the “wheel” group. By default, on CentOS 7, users who belong to the “wheel” group are allowed to use the sudo command.

# gpasswd -a moon wheel

Now new user “moon” have super user privileges.

STEP 3 – Securing the Server

Securing your server is to set up public key authentication for your new user. Setting this up will increase the security of your server by requiring a private SSH key to log in.

# ssh-keygen


STEP 4 – Copy the Public Key

Copy your public key to your new server, by using below steps.

Run the ssh-copy-id script by specifying the user and IP address of the server that you want to install the key on, like this # ssh-copy-id moon@100.12.111.112 You have generated an SSH key pair using the previous step, use the following command at the terminal of your local machine to print your public key # cat ~/.ssh/id_rsa.pub   

On the server, as the root user, enter the following command to switch to the new user (substitute your own user name)

 

# su - moon

Now you will be in your new user’s home directory.

 


 

 

 

 


	

Related posts

Leave a Comment