Archive

Archives pour 02/2024

Update locate database on OS X (updatedb)

27/02/2024 Comments off

Source: myunster.com

In order to update « locate » database on OS X, some people suggest create a symlink:

sudo ln -s /usr/libexec/locate.updatedb /usr/local/bin/updatedb

However, this method can create an erroneous output if you are in directory with specific permission e.g.

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
find: .: Permission denied

The better method would be create a bash script /usr/bin/updatedb:

  #!/bin/bash
  pushd . > /dev/null
  cd /usr/libexec
  echo "Updating locate database..."
  sudo ./locate.updatedb
  echo "Updating complete!"
  popd > /dev/null

Make it executable: sudo chmod +x /usr/bin/updatedb

Now you can just run «sudo updatedb», in order to update «locate» database.

Categories: Système Tags: , , , ,

Interdisez l’accès à votre serveur web par pays

26/02/2024 Comments off

Source: eric-couchelou.net

Linux-debian-300x145En annexe du paramétrage basique de votre serveur web, il se peut que vous soyez confronté à la nécessité ou l’envie de placer une interdiction d’accès Géolocalisée.

Mais avant de procéder à ce type d’installation, gardez à l’esprit plusieurs choses :

  • Si vous avez plusieurs sites sur le même serveur, tous seront concernés par vos règles, soyez donc sûr et certain qu’aucun d’entre eux n’ait pour cible l’un des pays que vous aller blacklister,
  • La très grande majorité des internautes des pays que vous pouvez considérer comme à risque (Russie, Chine, Taiwan, Roumanie, Brésil…) n’ont pas de mauvaises intentions, vous vous priverez donc volontairement d’une source de trafic potentiel.
  • Internet est ainsi fait que cette solution est loin d’être fiable à 100%, et les filtres géolocalisés facilement contournables

Bref, le jeu en vaut-il la chandelle? Si vous êtes convaincu que oui, alors ce petit tutoriel est fait pour vous. Je vous proposer d’installer le module de surveillance GEOIP.

1 – Installation du programme :

apt-get install libapache2-mod-geoip

2- Configuration du programme :

vi  etc/apache2/mods-available/geoip.conf

Et Mettre :

GeoIPEnable On
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat
SetEnvIf GEOIP_COUNTRY_CODE CN BlockCountry=1
SetEnvIf GEOIP_COUNTRY_CODE RU BlockCountry=1
SetEnvIf GEOIP_COUNTRY_CODE RO BlockCountry=1
SetEnvIf GEOIP_COUNTRY_CODE TW BlockCountry=1

Deny from env=BlockCountry

Chaque ligne de type SetEnvIf GEOIP_COUNTRY_CODE XX BlockCountry=1 correspond à une restriction d’accès pour un pays où XX définit le code du pays concerné par la règle. Pour info vous trouverez les différents codes pays (FR, DE, etc.) à cette adresse:
http://www.maxmind.com/app/iso3166

Redémarrez Apache :

/etc/init.d/apache2 restart

C’est en place!

Pour la mise à jour, téléchargez les dernières définitions d’IPs (une fois par mois pour la version gratuite) à cette adresse :
http://www.maxmind.com/app/geolitecountry

et remplacer celles existantes dans

/usr/share/GeoIP/GeoIP.dat

J’attire votre attention sur le fait que le blacklistage géolocalisé présenté ci-dessus fonctionne pour Apache, c’est à dire que vous devrez faire des paramétrages supplémentaires si vous voulez interdire les accès aux serveurs email par exemple. Nous verrons cela plus tard…

System: fail2ban and iptables

26/02/2024 Comments off

source: http://www.the-art-of-web.com/system/fail2ban/

Around the beginning of 2005 we saw an increase in brute-force ssh attacks – people or robots trying different combinations of username and password to log into remote servers. A quick search on this topic returns many references to iptables and ipchains but noone really explained how they work.

Having just gone through this learning curve myself, and found a satisfactory solution in the fail2ban package, I’m going to try and explain how to achieve the simple goal of banning IP addresses that make repeated failed ssh login attempts.

If you want more technical information regarding firewalls and iptables in particular, see the References section at the bottom of this page. Lire la suite…

How do I Find Out Linux CPU Utilization?

25/02/2024 Comments off

Source: nixCraft

Whenever a Linux system CPU is occupied by a process, it is unavailable for processing other requests. Rest of pending requests must wait till CPU is free. This becomes a bottleneck in the system. Following command will help you to identify CPU utilization, so that you can troubleshoot CPU related performance problems.

Finding CPU utilization is one of the important tasks. Linux comes with various utilities to report CPU utilization. With these commands, you will be able to find out:

* CPU utilization
* Display the utilization of each CPU individually (SMP cpu)
* Find out your system’s average CPU utilization since the last reboot etc
* Determine which process is eating the CPU(s)

Old good top command to find out Linux cpu load

The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel.
The top command monitors CPU utilization, process statistics, and memory utilization. The top section contains information related to overall system status – uptime, load average, process counts, CPU status, and utilization statistics for both memory and swap space.

Top command to find out Linux cpu usage

Type the top command:
$ top

Output:
linux-gui-info

You can see Linux CPU utilization under CPU stats. The task’s share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. In a true SMP environment (multiple CPUS), top will operate in number of CPUs. Please note that you need to type q key to exit the top command display.

The top command produces a frequently-updated list of processes. By default, the processes are ordered by percentage of CPU usage, with only the « top » CPU consumers shown. The top command shows how much processing power and memory are being used, as well as other information about the running processes.

Lire la suite…

Categories: Système Tags: ,

WordPress: Se protéger des spams sur les commentaires via un fichier .htaccess

25/02/2024 Comments off
Si vous autorisez vos visiteurs à poster des commentaires sur les articles de votre blog, vous avez certainement fait face aux robots spammeurs. Pour aider Askimet à lutter et réduire les attaques des spammeurs, il existe une astuce qui consiste à bloquer l’accès au fichier wp-comments-post.php qui permet de traiter la soumission des commentaires. Le code qui suit est à placer dans un fichier .htaccess à la racine de votre site Internet.

## ******** Pour se protéger contre des commentaires de Spam **********
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !.*mon-site.com.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) http://www.mon-site.com [R=301,L]