# How To Safely Disable Root Access On InterWorx

> After creating a new user on InterWorx, it's time to disable root access. To do that, we need to first give "sudo" control to the new user.

- Author: [Bhagwad Park](https://www.namehero.com/blog/author/bhagwad-park/)
- Published: 2019-10-14
- Updated: 2019-11-13
- Category: [InterWorx](https://www.namehero.com/blog/category/interworx/)
- Web page: https://www.namehero.com/blog/how-to-safely-disable-root-access-on-interworx/

In my earlier article on [creating a new user + shell](https://www.namehero.com/blog/how-to-create-a-new-vps-interworx-user-shell/), I’d explained that it’s a good idea to disable direct root access via SSH. One of the reasons why we see so many failed login attempts, is because spammers constantly bombard servers with fake credentials, searching for a way in. One solution was to [change the SSH port](https://www.namehero.com/blog/how-to-change-the-ssh-port-on-an-interworx-vps/), which some in the security industry classify as “security by obscurity”, and don’t view it as a valid measure (even though I disagree).

However, another way of inhibiting hackers from spamming your server and using up resources, is to simply disable root logins. In general, this is part of the overall security paradigm of never working directly with a root account in the first place. In Linux, any user can be configured to have administrative permissions via the “sudo” command.

So in this tutorial, we’re going to learn how to do the following:

1. Give an existing user “sudo” permissions
2. Disable root access

## Allowing a User to Access “Sudo”

If you disable root logins without first giving an existing user administrative permissions, you’ve effectively locked yourself out of the server! Since you can’t login as root, and no one else can perform root functions, you need to directly access the backend to undo the changes. So this is what we’re going to do first.

Right now, if we try and execute a sudo command with a fresh user, we see something like this:
 ![Trying to Execute sudo as a fresh user](https://blogcdn.namehero.com/startup/wp-content/uploads/2019/11/13131548/Cant-Execute-Sudo-Commands-1024x447.png)

This is because we need to add every user to whom we want to give “sudo” access, to the “sudoers” file. Here’s how to do it.

### Login as Root and Execute “visudo”

This is a root operation, so you’ll first need to login as root. Once inside, type the command “visudo”. This will open the “/etc/sudoers” file, but in a safe way with checks so that you don’t mess up anything too badly!

### Scroll Down to the Appropriate Line

The “vi” editor is very different from what you might be used to. It requires a specific set of keyboard presses. First, scroll down using the keyboard to the line that says this:

```
## Allow root to run any commands anywhere
```

Now position the cursor under the line starting with %wheel. Press the “Insert” button on your keyboard to enter editing mode. vi will now allow you to type in the command line.

Add the following:

```
**[username]**     ALL=(ALL)        ALL
```

Like this:
 ![Adding a user to the sudoers file](https://blogcdn.namehero.com/startup/wp-content/uploads/2019/11/13131646/Added-bhagwad-to-Sudoers-1024x422.png)

Replace **[username]** above, with the name of the user to whom you want to give “sudo” access. Once you’ve finished typing, press the “Escape” button a couple of times. This will exit the editing mode. Now type “ZZ” (Shift + Z + Z). This will save the changes and exit visudo.

### Verifying that it Works

Now let’s see if it works. Try and do the same operation that we did before. This time, it asks for the password and the command goes through as expected:
 ![sudo command now working](https://blogcdn.namehero.com/startup/wp-content/uploads/2019/10/14131619/sudo-command-now-working-1024x597.png)

So that’s working!

## Disabling Root Access

Now that we’re capable of executing root commands via an existing user, it’s safe to disable root. Here’s how to do it. Access your InterWorkx dashboard, and go to system services as shown here:
 ![SSH Server on InterWorx](https://blogcdn.namehero.com/startup/wp-content/uploads/2019/10/02123104/SSH-Server-on-InterWorx-1024x454.png)

Now on the right-hand side, select to disable root logins as shown in this screenshot:
 ![Disable Root Login](https://blogcdn.namehero.com/startup/wp-content/uploads/2019/10/14131609/Disable-Root-Login-1024x578.png)

Update your changes and you’re done!

## Testing Root Access

Now exist your shell and try and log in again. If all goes well, you should be met with an “Access Denied” message as shown here:
 ![Root Access Denied](https://blogcdn.namehero.com/startup/wp-content/uploads/2019/10/14131628/Root-Access-Denied-1024x475.png)

This is working as intended. It’s widely considered a bad idea to log in as root, or even to work directly with the root account. Hopefully, this tutorial will make your server just a little bit safer!

## Related posts

- [How To Disable Root Logins On Linux](https://www.namehero.com/blog/how-to-disable-root-logins-on-linux/)
- [How To Give Someone Temporary Root Access](https://www.namehero.com/blog/how-to-give-someone-temporary-root-access/)
- [How To Disable Root SSH Login In WHM](https://www.namehero.com/blog/how-to-disable-root-ssh-login-in-whm/)
- [Should You Look For Root Access In A VPS?](https://www.namehero.com/blog/should-you-look-for-root-access-in-a-vps/)
