---
title: "Creating New Users in CentOS 7"
description: "In this article, we're going to show you how you can create a new user in CentOS Cloud Servers. This is a task you will want to complete as soon as possible during your initial VPS setup phase,..."
url: https://www.inmotionhosting.com/support/product-guides/vps-hosting/how-to-create-a-new-user-in-centos-7/
date: 2018-06-27
modified: 2024-10-31
author: "Christopher Maiorana"
categories: ["VPS Hosting"]
type: post
lang: en
---

# Creating New Users in CentOS 7

![How to Create a New User in CentOS](https://www.inmotionhosting.com/support/wp-content/uploads/2018/06/canva-create-new-user-centos-1024x538.jpg)

In this article, we’re going to show you how you can create a new user in CentOS **[Cloud Servers](https://www.inmotionhosting.com/cloud-vps)**. This is a task you will want to complete as soon as possible during your initial [VPS ](https://www.inmotionhosting.com/vps-hosting)setup phase, because you are advised against using the default “root” user account for your daily tasks. Below, we will also show you how to:

- [How to Create a New User in CentOS](#create)
  - [Disallow Root Logins](#disallow)
- [Login with SSH Keys](#login)
  - [Next Steps](#next)

## How to Create a New User in CentOS

Remember that we are currently assuming the *root* user when first logging into the VPS. Without a *superuser* account, these commands would require that you add “sudo” at the beginning of the command line in order to run properly.

Be sure to substitute your custom username in place of “username” as used below.

1. Create the user with this command: adduser username
2. Assign a secure password for this user: passwd username
3. Add the user to the wheel group: usermod -a -G wheel username

Now we have a new user who belongs to the “wheel” group. Being in the wheel group means that the user can assume root privileges when necessary by adding “sudo” before any command that requires elevated privileges.

### Disallow Root Logins

As an extra security step after you create a new user, you can disallow root logins over SSH. In order to do this, you can log in again as the root user or stay logged in from the session above in order to edit your SSH configuration file.

1. Edit the configuration file with your preferred text editor (Nano, Vim, Vi, etc.): nano /etc/ssh/sshd_config
2. Edit the line that begins with *PermitRootLogin*: - PermitRootLogin without-password + PermitRootLogin no
3. Save and exit the file.
4. Restart your SSH service: systemctl reload sshd

## How to Login with SSH Keys

This is very important to set up because your account automatically disables password authentication. This means you will need to log in with SSH keys in order to use your new user.

1. Switch to your new user if still logged in as root: su username
2. Change directory to home: cd
3. Make an .ssh directory: mkdir .ssh
4. Navigate into the new .ssh directory and create an authorized_keys file: nano authorized_keys
5. Paste your public key into the *authorized_keys* file. This would be everything in the .pub file from your current SSH key.
6. Change permissions for the *.ssh* directory: chmod 700 ~/.ssh
7. Change permissions for the *authorized_keys* file: chmod 600 ~/.ssh/authorized_keys

### Next Steps

Make sure to test your new login in a separate terminal window before logging out of the root user. If there are any issues, you can resolve them in that terminal session. Once you’ve completed this task, consider taking additional steps to secure your Linux server. Change the default SSH port from 22 to uncommonly used port to defend against malicious port scans and SSH-based cyber attacks. Learn how to audit your web server logs or implement a security event management application to track SSH login attempts. Find some valuable [CentOS hardening](https://wiki.centos.org/HowTos/OS_Protection) guides.

Learn more system administration tasks with our [Cloud Server Hosting Product Guide](https://www.inmotionhosting.com/support/product-guides/vps-hosting/).
