Category Archives: CentOS6

Enable remote access to your MySQL Database on CentOS 6

Often you’ll need some remote access to your database in order to retrieve or manage data.

This can be set up quite easy.
First step would be to allow the network to access the mysql service. This is done by editing the /etc/my.cnf configuration file.
nano /etc/my.cnf
Now look for the line which contains # skip-networking and uncomment it.
Save the configuration file and restart the mysql service.

service mysqld restart

Now that you just allowed network access to your MySQL server you probably need to assign some credentials for remote access.
First login to your db:

mysql -u root -p mysql

Then you’re ready to create a database:

mysql> CREATE DATABASE database;

create a username for remote access:

mysql> GRANT ALL ON database.* TO user@’host’ IDENTIFIED BY ‘PASSWORD’;

or grant access to an already existing database:

mysql> update database set Host=’202.54.10.20′ where Db=’database’;
mysql> update user set Host=’202.54.10.20′ where user=’admin’;
Note: to grant access to any host use the wildcard ‘%’ instead of a host name/ host ip.

Setup a FTP server on CentOS6

So it’s close to a half a year since I started maintaining my own CentOS server, but did not set up a FTP server on it, therefore file transfers were quite tedious to accomplish.

So I went on googling about a lightweight linux ftp server and I stumbled upon vsftp and I thought I could make use of it as a service (vsftpd).
But before you think about setting a FTP server you might want to check on whether or not you already have one already opened (which was in my case).
You could check for the processes running the following command:
netstat -tulnp|grep :21

If you find that you have one already functioning and running you might want to check how to configure it and make use of it otherwise you could make use of vsftpd.
First proceed with installing the server which is as simple as:
yum install vsftpd
Then configure it for your need. You might want to make it as secure as possible, if that’s the case follow these steps then take a closer look at the reference.
Edit the configuration file /etc/vsftpd/vsftpd.conf with your editor of choice and modify the following:

We don’t want anonymous login:

anonymous_enable=NO

Enable local users:

local_enable=YES

The ftpuser should be able to write data:

write_enable=YES

Port 20 need to turned off, makes vsftpd run less privileged:

connect_from_port_20=NO

Chroot everyone:

chroot_local_user=YES

set umask to 022 to make sure that all the files (644) and folders (755) you upload get the proper permissions.

local_umask=022

Then prepare a user for FTP use:

useradd -d /var/www/path/to/your/dir ftpuser
passwd ftpuser
And give it access to the FTP root directory:
chown -R ftpuser /var/www/path/to/your/dir
sudo chmod 775 /var/www/path/to/your/dir

When ready you can start your service with:
service vsftpd start
and make it automatically start at boot time with:
chkconfig vsftpd on

Bring Xfce to a CentOS 6 box

[last update 11-01-2013]
As many of the tutorials about this subject, present on the Internet were either outdated
or incomplete, I thought to log my adventure into installing CentOS 6 with Xfce on my
recently rented VPS server.
So all you’ll need is SSH access to your box, and to be ready to get your hands dirty.
Log in with your root account into the box’s shell:
ssh root@host
The next thing to do is to enable a extra repository in order to be able to install Xfce on
your box. I recommend to use the EPEL {Extra Packages for Enterprise Linux} repository
and to do so you need to find the latest epel-release package; and to do so I used the official rpm package.
You might be lucky and at the time of reading this to be able to install this package
directly from CentOS6’s repos with:
yum install epel-release
but if your a bit less lucky install it manually:
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
Now that you are all set up with the EPEL repo, let’s go on with installing Xfce applications CentOS collection
yum groupinstall Desktop Xfce Fonts
After the packages installation is all done you need to set up a vnc server, after all there 
is no point in installing a Desktop Manager if you don’t intend to connect to it and see it. 
yum install tigervnc-server
Now make sure all your packages are updated:
yum update
At this point if you don’t already have a user besides the root user, you should create one
and assign it the desktop by setting a vnc password for it. I’ll use the name gui in these
examples.
useradd gui
passwd gui
su gui
vncpasswd
Now enter a password for the desktop user, this password will be when you’ll remote
connect to the newly installed server. After that return to your root shell user with the
exit command.
exit

Now it’s time to configure the vnc server configuration, but first we need a CLI text
editor to edit the configuration, I’ll use nano for that.
yum install nano
nano /etc/sysconfig/vncservers
The configuration file should reflect which user is going to be responsible for the
Graphical User interface and how the desktop would be like. So I’ll use a simple
configuration:
VNCSERVERS=”1:gui”
VNCSERVERARGS[1]=”-geometry 1024×768  -nolisten tcp -localhost
Important note: The italic part should be added to secure the connection with a SSH tunnel
Note: make sure this two lines are uncommented
Now let’s quickly start and stop the vncserver in order to get the default startup
configuration file ready. So ..
service vncserver start
Now you are ready to log in using the VNC client of your choise. I use RealVNC, but any
client would do the job.
If you didn’t use SSH tunneling for your setup then you can connect by providing
host:1 and your vnc password to any VNC client.
Now let’s add this server to the startup configuration:
ntsysv
Check vncserver and press ok. From now on your vnc server will start at boot time.
If you createad a secure vnc connection open a tunnel first
I love this lightweight desktop, it takes just about 100MB of RAM on the server and is not
wasting valuable resources.