-1

I have installed nginx on my centos 7 server, now i'm going to create a server block but i wonder if it's necessary to use a non-root user?

I am following this tutorial on DigitalOcean and it states that i need a non-root user:

You will need access to a CentOS 7 server with a non-root user that has sudo privileges.

This is my private server and i will always be the only admin of it, why can't i use root user to do it?

  • 3
    Necessary? No. Wise? Yes. See https://askubuntu.com/questions/16178/why-is-it-bad-to-log-in-as-root, https://unix.stackexchange.com/questions/52268/why-is-it-a-bad-idea-to-run-as-root, etc. – ceejayoz May 19 '18 at 16:26
  • So, I've created a few directories which i'm going to use in my non-root user and set pm2 to start on startup (sudo pm2 startup systemd), do I have to change anything to make pm2 run safe & gain access to files i've created on root? It's my first time working with a server. @ceejayoz – user123 May 19 '18 at 17:09
  • 1
    What is pm2 meant for here? It's pretty much obsolete. And it's not even in that tutorial. – Michael Hampton May 19 '18 at 17:24
  • It's in link, i don't know if it would affect security or not if its run by root. PM2 is what i run on root, i did nothing else except creating folders and i wonder if it's a problem. – user123 May 19 '18 at 17:30

2 Answers2

1

Once someone else gets the root access, game is over. Having a separate user for SSH login and disabling root login adds an extra layer of security where an intruder needs to first be able to access the system as a normal user and then elevate privileges.

If you are the only admin, using root account instead of sudo might actually be more secure with password authentication, as there are two different passwords to know. With the login user in sudoers group it's better to use SSH keys instead of password login, and password only for the sudo.

Esa Jokinen
  • 49,773
0

I think they meant minimum requisites. The reason you need superuser access is that you are installing a software via the yum package manager, and also the daemon will need root permissions to start.

So answering your question, it is ok to use a non-root user with sudo privileges or a root user