Monday, June 28, 2010

How to Set Hostname on CentOS (RHEL)

Setting the hostname on CentOS (RHEL).

Well, I could have sworn when I ordered this VPS that I entered the hostname I wanted in the order form. I guess I must have been hallucinating....

Begin by checking the existing hostname using the hostname command.
login as: root
root@vps12's password:
Last login: Mon Jun 28 16:21:53 2010
[root@vps12 ~]# hostname
vps12
We can also check via sysctl kernel.hostname
[root@vps12 ~]# sysctl kernel.hostname
kernel.hostname = vps12
The actual hostname I need to set for this server is blanche.mydomain.net

I can set the hostname initially using the hostname command followed by the desired hostname.
[root@vps12 ~]# hostname blanche.mydomain.net
This will set the hostname:
[root@vps12 ~]# hostname
blanche.mydomain.net
However, once the server is rebooted, the hostname will revert to it's previous setting (vps12).

To permanently change the hostname, I need to edit the network file at /etc/sysconfig/network.

So,
[root@vps12 ~]# cd /etc/sysconfig
[root@vps12 sysconfig]# vi network

The Network file will look as so.

NETWORKING=yes
HOSTNAME=vps12
GATEWAYDEV=eth0
GATEWAY=192.168.0.1

Hit 'i' to insert and change the HOSTNAME value to your FQDN, in my case, blanche.mydomain.net

Hit Escape, then :wq to save and exit.

Check that the hostname is properly set:
[root@vps12 sysconfig]# hostname
blanche.mydomain.net
[root@vps12 sysconfig]# sysctl kernel.hostname
kernel.hostname = blanche.mydomain.net

Finally, if we log out, and log back in using a new session, we see I am now root@blanche:
login as: root
root@blanche's password:
Last login: Mon Jun 28 16:21:53 2010
[root@blanche ~]#  

To properly check, you may wish to reboot the server.

How to Enable Root Login (CentOS / RHEL)

Disclaimer: It's always best practice that any machine on the internet not allow direct Root login via SSH.

To allow Root to log in, we need to update our sshd_config file located at /etc/ssh/sshd_config.

To update this file, we need to switch over to Root:
[admin@blanche ~]$ su root
Password:
[root@blanche ~]#

Go to the /ect/ssh directory:
[root@blanche ~]# cd /etc/ssh
[root@blanche ssh]#

Now, let's edit our sshd_config file using vi:
[root@blanche ssh]# vi sshd_config

Look for the following section (about 1/3 of the way down):
#LoginGraceTime 2m
PermitRootLogin no

Hit "i" to insert and then change the value for PermitRootLogin from no to yes.

Hit Escape and then :wq! to save changes and close the file.

Finally, still as Root, we need to restart SSHD using /etc/init.d/sshd restart.

[root@blanche ssh]# /etc/init.d/sshd restart
Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]

Exit your session, open a new terminal and confirm you are now able to login as Root:

login as: root
root@blanche's password:
Last login: Mon Jun 28 16:21:53 2010
[root@blanche ~]#

Saturday, June 5, 2010

Install Webmin on CentOS 5

Some months ago, the download url for Webmin was updated.

You can find the latest release at: http://www.webmin.com/download.html

SSH to your server.
[root@server7]# yum -y install perl-Net-SSLeay
Get the rpm.
[root@server7]# wget http://prdownloads.sourceforge.net/webadmin/webmin-1.510-1.noarch.rpm

Verify using MD5 - Webmin also offers PGP Verification.

To do this, use the md5sum command

[root@server7]# md5sum webmin-1.510-1.noarch.rpm
7d7167b0f62e7f0a5578a6117581c46f  webmin-1.510-1.noarch.rpm

Compare the output above to the official MD5 Checksum on the Webmin Site.


The MD5 Checksum listed on the Webmin site, 7d7167b0f62e7f0a5578a6117581c46f, matches our output above, so we are ready to install.


Install the rpm.
[root@server7]# rpm -i webmin-1.510-1.noarch.rpm 

You should get a message at the end of the install informing you that you can reach the installation at:

https://hostname(or server IP):10000