Como instalar e configurar o CSF

Dicas,Tutoriais 10 dezembro 2010 | 7 Comments

Infelizmente nem todas as pessoas tem o discernimento para compreender a importância de um firewall bem configurado e ativo, então muitos acabam deixando essa proteção de lado por preguiça e/ou “conveniência” e uma hora você pagará caro por isso, pode ter certeza.

O CSF é uma solução completa de firewall que trabalha de forma inteligente e eficaz protegendo o seu servidor de várias ameaças.

A instalação do CSF é bem simples e para fazê-la basta rodar a linha de comando abaixo:

cd /etc; wget http://www.configserver.com/free/csf.tgz; tar -xzf csf.tgz; cd csf; sh install.cpanel.sh

Quando o CSF terminar de instalar você deve editar no arquivo /etc/csf/csf.conf o valor da linha (logo no começo) TESTING que estará como “1″ para “0″, e então execute a linha de comando:

csf -u; csf -r

Abaixo encontram-se alguns comandos que são básicos e frequentemente utilizados:

csf -g IP => Verificar se o IP está bloqueado

csf -d IP “Motivo – Seu Nome” => Vai bloquear o IP no firewall e adicionar o comentário no arquivo /etc/csf/csf.deny

csf -dr IP => Comando para remover o bloqueio definitivo de um IP

csf -tr IP => Comando para remover o bloqueio temporário de um IP

csf -a IP “Motivo – Seu Nome” => Adicionar um IP a lista branca do firewall, extremamente recomendado que se utilize com cautela e somente com IPs fixos.

grep IP /var/log/lfd.log => Verificar o motivo de um bloqueio temporário.

Uma dica importante é que vocês leiam os comentários do arquivo /etc/csf/csf.conf que possui muitas funções interessantes e que podem ser exploradas para melhor eficiência da segurança e até desempenho de seu servidor.

Desativar o firewall de seu servidor não deve ser uma opção, se você encontrar algum problema vá atrás da solução.

Abraços!

Tags: , , ,

Como corrigir o horário de um VPS no OpenVZ

Dicas,Tutoriais 10 dezembro 2010 | 0 Comments

Você tenta alterar o horário dos servidores virtuais (VPS) de seus clientes e não consegue? Aqui está a solução! Primeiro você deve parar o VPS com o comando:

vzctl stop VEID

Então execute o comando:

vzctl set VEID --capability sys_time:on --save

Inicie o VPS e acesse-o:

vzctl start VEID
vzctl enter VEID

Então digite

mv /etc/localtime /etc/localtime.old
ln -s /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime

Caso deseje configurar um outro fuso horário, basta procurar a cidade no diretório /usr/share/zoneinfo/. Após isto digite date e verifique se o hora/data estão corretos.

*Lembre-se que o VEID deve ser substituído pelo ID do VPS no OpenVZ. Você pode verificar todos os VPS que estão criados em seu OpenVZ com o comando:

vzlist -a

Abraços!

Tags: , , , ,

URGENTE: Vulnerabilidade no Exim

Dicas 10 dezembro 2010 | 0 Comments

Acabei de receber o seguinte e-mail na lista do cPanel:

=============
Summary
=============
A privilege escalation vulnerability exists in Exim, the mail transfer agent used by cPanel & WHM.

———————–
Security Rating
———————–
This update has been rated as Critical by the cPanel Security team.

Description
———————–
Research up to this point indicates the exploit is a buffer overflow vulnerability that takes advantage of the default Exim configuration settings related to altering Exim’s runtime configuration file along with overriding the macro definitions in the configuration file. This buffer overflow may lead to arbitrary code execution with the privileges of the user executing the Exim daemon. However, the Exim user retains root privileges when running the -C and -D command line flags. Through the creation of a temporary exim configuration which is processed with the -C or -D flags, the Exim user is able to execute arbitrary commands as root.

Solution
———————–
To resolve and work around the issue, for Linux-based systems cPanel has issued new Exim RPMs. The new version of Exim locks configuration file locations to the /etc/exim prefix as well as disabling use of the -D flag. Server Owners are strongly urged to upgrade to the following Exim RPM versions:

• Systems configured to use Maildir: Exim 4.69-25
• Systems configured to use mbox (deprecated): Exim 4.63-4

Exim RPMs will be distributed through cPanel’s package management system. All cPanel & WHM servers receiving updates automatically will receive the updated Exim RPM during normal update and maintenance operations (upcp).  If you prefer to install the update right now, please run the following in a root shell:

/scripts/eximup

On cPanel & WHM FreeBSD servers, Exim is an unmanaged install performed from the Ports system. To apply a like setup on FreeBSD systems, server administrators will need to perform the following manual configuration:

•  Remove WITHOUT_ALT_CONFIG_PREFIX=yes from /etc/make.conf
•  Add the following to /var/db/ports/exim/options

WITH_ALT_CONFIG_PREFIX=true
SEDLIST+= -e ‘s,^(ALT_CONFIG_PREFIX=).*,\1/

etc/exim,’
SEDLIST+= -e ‘s,^\# (DISABLE_D_OPTION=),\1,’

• Change directory to /usr/ports/mail/exim
• Execute ‘make deinstall’
• Execute ‘make install’

Caution: the above changes have potential to be undone by /scripts/checkmakeconf, and updates to the Exim port. An upcoming version of cPanel & WHM 11.28 will resolve this for FreeBSD users.

References
———————–
http://docs.cpanel.net/twiki/bin/view/AllDocumentation/SecurityLevels
http://www.exim.org/lurker/message/20101207.215955.bb32d4f2.en.html

Atualizem o mais rápido possível o Exim de seus servidores com o comando /scripts/eximup. Se você utilizar o FreeBSD a atualização vai requerer uma atenção especial.
Boa sorte!

Tags: , ,

Como ativar a compressão gzip através do mod_deflate (Apache)

Dicas,Tutoriais 9 dezembro 2010 | 0 Comments

Opa pessoal, quanto tempo hein?! Estou de volta para dar mais uma dica para vocês, desta vez é a ativação do mod_deflate para otimizar o acesso de seus sites através da compressão gzip.

Primeiramente você precisa do mod_deflate instalado, para verificar digite:

root@localhost(~)$ httpd -l | grep deflate
mod_deflate.c
root@localhost(~)$

Se não tiver instalado, instale recompilando o Apache/PHP através do Easyapache (/scripts/easyapache). O primeiro passo é criar o arquivo /usr/local/apache/conf/deflate.conf com o seguinte conteúdo:

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>
DeflateCompressionLevel 9
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE application/x-httpd-eruby
AddOutputFilterByType DEFLATE image/svg+xml

Após criar o arquivo e inserir o conteúdo acima, edite o arquivo /usr/local/apache/conf/includes/pre_main_global.conf inserindo a seguinte linha:

Include "/usr/local/apache/conf/deflate.conf"

Reinicie o Apache com o comando /scripts/restartsrv httpd e realize testes através do link http://www.whatsmyip.org/http_compression/.

PS: Localizei problemas com players SWF, se algum cliente reclamar recomendo desativar o mod_deflate (removendo a linha acima e reiniciando o Apache) ou caso encontre a solução compartilhe conosco!

Abraços!

Fonte: http://encurta.com/f41

Tags: , ,

ERRO => MySQL: mysql is not running but lock exists

Dicas 21 agosto 2010 | 0 Comments

Se você digitar o comando:

/etc/init.d/mysql status

E o resultado for algo parecido com:

mysql is not running but lock exists

Basta rodar o comando:

rm /var/lock/subsys/mysql

Agora inicie o MySQL, o mesmo deve iniciar sem problemas. Até a próxima pessoal!

Fonte: http://encurta.com/488b2

Tags: ,