Monday, 4 June 2012

Thwart attacks to your SFTP server with DenyHosts

For automated blocking of attackers try denyhosts. DenyHosts is a script intended to be run by Linux system administrators to help thwart SSH server attacks (also known as dictionary based attacks and brute force attacks).

http://www.cyberciti.biz/faq/block-ssh-attacks-with-denyhosts/


Saturday, 24 March 2012

ClamAV 97.4 error while loading shared libraries

I installed ClamAV 0.97.4 on my Kubuntu system today, the installation went OK and no error were shown but when I tried to run virus scanning I got this error message:

Quote:   
clamscan: error while loading shared libraries: libclamav.so.6: cannot open shared object file: No such file or directory
   


A quick browse and found that the following fixed this:
Code:   
sudo ldconfig
   

Tuesday, 6 March 2012

20 Linux System Monitoring Tools Every SysAdmin Should Know

Very good article on some essential monitoring tools.

http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html

iptables: Blocking attacking IP addresses

Excellent article on using iptables to block an attacking IP address.

http://www.cyberciti.biz/faq/linux-iptables-drop/

I needed to block a known russian SSH/SFTP hacker.

Code:   
iptables -A INPUT -s 91.205.189.27/255.255.255.255 -j DROP
   


Even better for automated blocking of attackers is denyhosts. DenyHosts is a script intended to be run by Linux system administrators to help thwart SSH server attacks (also known as dictionary based attacks and brute force attacks).

http://www.cyberciti.biz/faq/block-ssh-attacks-with-denyhosts/

Sunday, 12 February 2012

Copy table between two Databases

Code:   
CREATE TABLE DB2.new_copy LIKE DB1.master_copy;
INSERT INTO DB2.new_copy SELECT * FROM DB1.master_copy;


The first line creates the table using the same engine as the existing table and creates the primary keys and/or indexes.
The second line copies the data across.

If the original table has many keys then it may help to speed the INSERT if you turn off the keys using the following before the INSERT:

Code:   
ALTER TABLE new_table_name DISABLE KEYS;
   
And then after the INSERT:

Code:   
ALTER TABLE new_table_name ENABLE KEYS;
   
These two statements are not supported by all MySQL Engine types though. InnoDB being one of them in MySQL ver 5.x



Linux: 20 Iptables Examples For New SysAdmins

Very good article on some essential iptables firewall rules.
http://www.cyberciti.biz/tips/linux-iptables-examples.html

Saturday, 10 December 2011

Select data from table WHERE not matched in another table

The following SQL example allow you to select data, excluding data that is in another table.

You can off course include more selection criteria after the WHERE clause.

Code:   
--  Select data from table WHERE not matched in another table
SELECT data_from_table.*
FROM data_from_table
LEFT JOIN exclude_table
ON data_from_table.email = exclude_table.email
WHERE exclude_table.email IS NULL;

So, data will be selected where the email address does NOT match an email address in table exclude_table.

You can exclude multiple tables...
Code:   
--  Select data from table WHERE not matched in another table
SELECT data_from_table.*
FROM data_from_table
LEFT JOIN exclude_table_1
ON data_from_table.email = exclude_table_1.email
LEFT JOIN exclude_table_2
ON data_from_table.email = exclude_table_2.email
WHERE exclude_table_1.email IS NULL
AND exclude_table_2.email IS NULL;

So, data will be selected where the email address does NOT match an email address in table exclude_table_1 and does NOT match an email address in table exclude_table_2.

For speed, make sure that the field/s you’re comparing in both tables are keys.