Summer Nights

Let's make the world a better place using digital technologies!

Use fail2ban to stop brute-force attacks

apt-get install fail2ban
That’s all it takes to install this handy utility. It will monitor different services (ssh, postfix, courier, etc.) for repeated failed login attempts and will block the attacker for a given duration of time. All the settings can be found in /etc/fail2ban/jail.conf.
After you have updated the settings file, use:
/etc/init.d/fail2ban restart
to reload the new settings.

I was having brute-force dictionary attacks on pop3 port, fail2ban blocked the attacker within 1 minute. Thanks to the developers.

Continue Reading

Some Useful MySQL Commands

  • mysql -uusername -ppassword
    gets you into MySQL shell
  • show databases;
    shows all the databases;
  • create database databasename;
    creates a new database
  • grant all privileges on databasename.* to 'user'@'localhost' identified by 'password';
    creates user with password with all privileges on given database
  • use databasename;
    selects a database for further actions
  • show tables;
    displays the tables in the selected database
  • drop database databasename;
    deletes all tables in databasename and deletes the database.
  • select * from mysql.user;
    lists all the mysql users
  • drop user xxxx@localhost;
    deletes the xxxx user from the localhost
  • mysqldump --all-databases -p | bzip2 -c > databasebackup.sql.bz2
    dumps all mysql data in the compressed databasebackup.sql.bz2 file.
  • mysqldump -uroot -p databasename | bzip2 -c > databasename.sql.bz2
    dumps databasename database in the compressed databasename.sql.bz2 file.
Continue Reading