Archive for the tag 'Root'

SBDavid

what is the root zone?

what is the root zone?

The DNS translates domain names that humans can remember into the numbers used by computers to look up its destination (a little like a phone book is used to look-up a phone number). It does this in stages. The first place it ‘looks’ is the top level of the directory service - or “root zone”. So to use www.google.com as an example, your computer ‘asks’ the root zone directory (or top level) where to find information on “.com”. After it gets a response it then asks the “.com” directory service identified by the root where to find information on .google.com (the second level), and finally asking the google.com directory service identified by “.com” what the address for www.google.com is (the third level). After that process – which is almost instantaneous – the full address is provided to your computer. Different entities manage each one of these directory services: google.com by Google, “.com” by VeriSign Corporation (other top level domains are managed by other organizations), and the root zone by ICANN.

SBDavid

Reset a lost MySQL root password

MySQL - reset a lost MySQL root password

The MySQL root password allows full access to the MySQL database and allows for all actions to be undertaken including creating new users, new databases, setting access rules and so on.

The first thing to do is stop MySQL.

sudo /etc/init.d/mysql stop

Now start mysql in safe mode.

Next we need to start MySQL in safe mode - that is to say, we will start MySQL but skip the user privileges table.

sudo mysqld_safe –skip-grant-tables &

*ampersand (&) at the end of the command is required.

Login

mysql -u root

Next, instruct MySQL which database to use:

use mysql;

Reset password
Enter the new password for the root user as follows:

update user set password=PASSWORD(”mynewpassword”) where User=’root’;

and finally, flush the privileges and then stop and start mysql.

flush privileges;
SBDavid

Disabling SSH Login for root user

Disabling SSH Login for root user

Below are instructions for disabling the root user and allowing another user to assume the root users permissions. This adds another layer of security because an additional username and password must now be entered before gaining the root user privileges.

Before you disable root logins you should add an administrative user that can ssh into the server and become root with su.

In the following example we are using buddy for the username, but can be replaced with any username you wish to use.

root@dell:~# useradd buddy
root@dell:~# id buddy
uid=1005(buddy) gid=1007(buddy) groups=1007(buddy)

Set the password for the buddy user. When prompted type and then retype the password.

root@dell:~# passwd buddy
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

SSH to the server with the new admin user and ensure that the login works.
Verify that you can su (switch user) to root with the admin user.

buddy@dell:/$ su
Password:
root@dell:/# whoami
root

Edit /etc/ssh/sshd_config with your favorite text editor.

#vi /etc/ssh/sshd_config

Change this line:

#PermitRootLogin yes

to this:

PermitRootLogin no

Ensure that you are logged into the box with another shell before restarting sshd to avoid locking yourself out of the server.

# /etc/init.d/sshd restart

Step 1 Add your admin user to the ‘wheel’ group so that you will be able to ’su -’ to root, otherwise you may lock yourself out of root.

Adding user to the wheel group.

usermod -g wheel username

Edit /etc/ssh/sshd_config file.

vi /etc/ssh/sshd_config

Next, find the line PermitRootLogin yes and Uncomment it and make it look like PermitRootLogin no

Now restart SSH

/etc/rc.d/init.d/sshd restart
SBDavid

Email Alert on Root SSH Login

Email Alert on Root SSH Login

Login to your server as root user

vi /root/.bashrc

Add the following to the end of the file.

echo ‘ALERT - Root Shell Access on $hostname:’ `date` `who` |
mail -s “Alert: Root Access from `who | cut -d”(” -f2 | cut -d”)” -f1`” admin@serverbuddies.com

Next »