Showing posts with label CentOS. Show all posts
Showing posts with label CentOS. Show all posts

23 Feb 2012

Directory listing timeout with ProFTPd in Centos and Virtualmin

I'm using Virtualmin to manage a Centos 5.7 machine.
When trying to use FileZilla to access the server using ftp I kept getting the following errors:

Status: Resolving address of servername.com
Status: Connecting to IP_ADDRESS:21...
Status: Connection established, waiting for welcome message...
Response: 220 FTP Server ready.
Command: USER my_username
Response: 331 Password required for servername.com
Command: PASS *******
Response: 230 User my_username logged in
Command: OPTS UTF8 ON
Response: 200 UTF8 set to on
Status: Connected
Status: Retrieving directory listing...
Command: PWD
Response: 257 "/" is the current directory
Command: TYPE I
Response: 200 Type set to I
Command: PASV
Response: 227 Entering Passive Mode (XXX,XXX,XXX,XXX,XXX,XXX).
Command: MLSD
Error: Connection timed out
Error: Failed to retrieve directory listing



However using Nautilus, Ubuntu's file explorer, I had no problem accessing the server.

It turned out to be some modules missing in the server, needed to assure the right support for passive ftp connection.

I just add to edit /etc/sysconfig/iptables-config to make sure it was loading ip_conntrack_ftp and ip_conntrack_tftp:


IPTABLES_MODULES="ip_conntrack_netbios_ns ip_conntrack_ftp ip_conntrack_tftp"


I then restarted iptables with:

/etc/init.d/iptables restart


And now I can access my files using any FTP client (at least it works with FileZilla :) )


7 Jun 2011

Stop ssh attacks with fail2ban in CentOS

Every server on the web is subject to frequent breaking attempts, and when there are services running on default ports like 22 for ssh it becomes even more common.

However, using a simple tool freely available called fail2ban we can easily keep those intruders out of our machines without having to change our service ports.

In order to get fail2ban working on a CentOS machine you just have to install it straight from the repositories using:

$ yum install fail2ban


And then edit the configuration file to activate ssh and adjust some key parameters.

#edit configuration using your favourite editor ( I like vi )
$ vi /etc/fail2ban/jail.conf 

To activate ssh access monitorization find [ssh-iptables] section and make it active
enabled  = true
and  point the script to the right log file
logpath  = /var/log/secure

Then you might want to change the following aditional parameters:

  • ignoreip - A comma separated list of IPs you consider safe and would like the script to ignore regarding access attempts (this comes in the top of the configuration file)
  • action - Change the sender and recipient emails to get notifications regarding fail2ban actions
  • maxretry - The maximum number of failed login attempts before an IP get banned
Now just restart the service
/etc/init.d/fail2ban restart
and test it. Just make sure you do not get locked out. Anyway, the ban will be released after 10 minutes (default value).


[UPDATE] Forgot to let you know that if you are using Ubuntu you can also install fail2ban from the repositories and it works straight out of the box with no additional configurations required:
$ sudo apt-get install fail2ban

9 Jul 2008

Error running Java applications in Centos 5

When trying to run a Java application on my Centos VE I got this error message:


#
# An unexpected error has been detected by Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00002aaaaaab4112, pid=3715, tid=1075882304
#
# Java VM: Java HotSpot(TM) 64-Bit Server VM (1.6.0_03-b05 mixed mode)
# Problematic frame:
# C [ld-linux-x86-64.so.2+0x9112]
#
# An error report file with more information is saved as hs_err_pid3715.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
Aborted


To solve this error, related with some libraries we use prelink.

If it is not already installed we can install it like this:
# yum install prelink

And then we run prelink:
# /usr/sbin/prelink -amR

Installing Java 6 in a Centos 5 VE

Download Java installation package from:
http://java.sun.com/javase/downloads/index.jsp

Select the version you want and click download.
Then you'll have to select the platform where java will be installed (Linux x64, for me) and check the licence agreement.

In the next page I select to download the "Linux x64 RPM in self-extracting file" and then the download starts using SUN's Download Manager.

With the package copied to the VE in which we want to install Java we must make it executable:

# chmod a+x jdk-6u3-linux-amd64-rpm.bin

And install it:

# ./jdk-6u3-linux-amd64-rpm.bin

Check that the right version is available now:

# java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_03-b05, mixed mode)
#

3 Jun 2008

Creating a Minimal CentOS 5.1 VE in OpenVZ

These steps are for those with OpenVZ already installed and running.

Move to the templates directory:

# cd /vz/template/cache

Download CentOS 5.1 template:

# wget http://download.openvz.org/template/precreated/contrib/centos-5-i386-minimal.tar.gz

Create the VE:

# vzctl create --ostemplate centos-5-i386-minimal


Set VE's IP address:

# vzctl set --ipadd --save

Set VE's hostname:

# vzctl set --hostname --save

Set root's password:

# vzctl set --userpasswd root:password

Start the VE:

# vzctl start

Trying to enter the VE now I got an error:

# vzctl enter
enter into VE failed
Unable to open pty: No such file or directory


We can solve this with:

# vzctl exec /sbin/MAKEDEV tty
# vzctl exec /sbin/MAKEDEV pty
# vzctl exec /sbin/MAKEDEV ptmx
# vzctl exec /sbin/MAKEDEV random
# vzctl enter

Then we remove udev package like this:

# rpm -qf /etc/udev/makedev.d/50-udev.nodes
udev-095-14.9.el5
# rpm -e udev-095-14.9.el5 –nodeps


Now we can restart the VE and we are ready to go.