La configurazione dipende da quale chiavetta internet si sta utilizzando… comunque queste si possono considerare come linee guida

Take a look at the output of lsusb. You should see your modem assigned to ttyUSB* ports:

sudo ls /dev/ttyUSB*
ttyUSB0 – Should be the modem
ttyUSB1 – Should be the USB module

Download a dialer

sudo apt-get install wvdial ppp
Configure your connection

gksudo gedit /etc/wvdial.conf
and use something like the following:

[Dialer hsdpa]
Phone = *99***1#
Username = vodafone
Password = vodafone
Stupid Mode = 1
Dial Command = ATDT
Modem = /dev/ttyUSB0
Baud = 460800
Init2 = ATZ
Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ISDN = 0
Modem Type = Analog Modem
You need to set your Phone number, username and password, these are values given by your operator.

Also set the connection on Modem (/dev/ttyUSB0)

The name hsdpa, is generic, you can use whatever name you want.

When dialing your connection, is this name you use.

If using PIN code add this before Init2

Init1 = AT+CPIN=9999
where 9999 is changed for your PIN-code

Start your connection

sudo wvdial hsdpa


yum install mod_ssl openssl

# Generate private key 
openssl genrsa -out ca.key 2048 

# Generate CSR 
openssl req -new -key ca.key -out ca.csr

# Generate Self Signed Key
openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt

# Copy the files to the correct locations
cp ca.crt /etc/pki/tls/certs
cp ca.key /etc/pki/tls/private/ca.key
cp ca.csr /etc/pki/tls/private/ca.csr

<VirtualHost *:80>
        <Directory /var/www/vhosts/>
        AllowOverride All
        DocumentRoot /var/www/vhosts/

NameVirtualHost *:443

<VirtualHost *:443>
        SSLEngine on
        SSLCertificateFile /etc/pki/tls/certs/ca.crt
        SSLCertificateKeyFile /etc/pki/tls/private/ca.key
        <Directory /var/www/vhosts/>
        AllowOverride All
        DocumentRoot /var/www/vhosts/

/etc/init.d/httpd restart

iptables -A INPUT -p tcp --dport 443 -j ACCEPT
/sbin/service iptables save
iptables -L -v

quick hacks

copy files from a directory to a destination by number offset:


#!/usr/bin/perl -w

use strict;
use Getopt::Std;
use File::Copy;

my %opts = ();
getopts('d:n:f:', \%opts);

my $dir = $opts{d};
my $num = $opts{n};
my $frm = $opts{f};
my $to_dir = '/var/log/'.$dir;

die "no directory : [$dir]\n"  unless -d $dir;
die "no files specified : [$num] (must be a number)\n" unless $num =~ m/^\d+$/;
if(defined($frm)) {
  die "no offset specified : [$frm] (must be a number)\n" unless $frm =~ m/^\d+$/;

print “processing dir :[$dir]\n”; print “files :[$num]\n”; print”reading dir ….\n”; opendir(DIR, $dir) || die “can’t opendir $dir: $!”; my @files = grep { ! /^\./ && -f “$dir/$_” } readdir(DIR); closedir DIR; print”dir read ….\n”; my $from = $frm || 0; print”>>DEBUG>>from:[$from]\n”; for (0 .. ($num – 1)) { $_ += $from; print”copying file:[$dir/$files[$_]] => $to_dir\n”; copy(“$dir/$files[$_]”, $to_dir) or die “copy failed : $!\n”; } __END__


1. Firstly, generate your public/private keys using ssh-keygen

% ssh-keygen -t rsa

You must use the -t option to specify that you are producing keys for SSHv2 using RSA. This will generate your id_rsa and in the .ssh directory in your home directory. I strongly suggest using a passphrase.

2. Now copy the to the .ssh directory of the remote host you want to logon to as authorized_keys2 .

[Note: If you have more than one host from which you want to connect to the remote host, you need to add the local host’s as one line in the authorized_keys2 file of the remote host, i.e., you can have more than one entry. Thanks to Jinn Koriech for pointing this out. Also, you need to ‘chmod 644 authorized_keys2’ to make it unwritable to everybody apart from the user. Thanks to Matthew Lohbihler for this info.]

You are basically telling the sshd daemon on the remote machine to encrypt the connection with this public key and that this key is authorized for version 2 of the ssh protocol. Try using something secure like scp for this copying.

% scp ~foo/.ssh/ [email protected]:~foo/.ssh/authorized_keys2




Convert OpenSSH? to IETF SECSH key file


Usage: ssh-keygen [options]
  -b bits     Number of bits in the key to create.
  -c          Change comment in private and public key files.
  -e          Convert OpenSSH to IETF SECSH key file.
  -f filename Filename of the key file.
  -g          Use generic DNS resource record format.
  -i          Convert IETF SECSH to OpenSSH key file.
  -l          Show fingerprint of key file.
  -p          Change passphrase of private key file.
  -q          Quiet.
  -y          Read private key file and print public key.
  -t type     Specify type of key to create.
  -B          Show bubblebabble digest of key file.
  -C comment  Provide new comment.
  -N phrase   Provide new passphrase.
  -P phrase   Provide old passphrase.
  -r hostname Print DNS resource record.
  -G file     Generate candidates for DH-GEX moduli
  -T file     Screen candidates for DH-GEX moduli


ssh-keygen -e -f >



rename a table

RENAME TABLE old_table TO tmp_table,
             new_table TO old_table,
             tmp_table TO new_table;


re-index massive tables that are taking too long to re-index and are highly volatile


  • rename the table to something and create a table to accept incoming (temporary data)


    rename table status_log to status_log_maint; rename table status_log_temp to status_log;


  • optimise the renamed table


    optimize table status_log_maint


  • move big table back into place


    rename table status_log to status_log_temp; rename table status_log_maint to status_log;



  • move data back again:


    insert into status_log 
              (status_log_datetime, status_log_task_id, status_log_type, status_log_description, 
               status_log_status, status_log_booked_to_id, time, run_at_server) 
    select status_log_datetime, status_log_task_id, status_log_type, status_log_description, 
    status_log_status, status_log_booked_to_id, time, run_at_server 
    from status_log_temp;


  • remove temp table


    drop table status_log_temp



MySQL command mysqlcheck

this can be run whilst mysql is running, unlike myasmchk which ideally shouldn’t be run on a live mySQL server


  • mysql – rebuild indexes by database in crontab


	* 00 11 * * * /usr/local/mysql/bin/mysqlcheck -u<user> -p<password>  
  --repair --quick --databases <db name(s)> --silent


  • mysql – rebuild indexes by table(s) in crontab


	* 00 11 * * * /usr/local/mysql/bin/mysqlcheck -u<user> -p<password>  
  --repair --quick <database> <table name(s)(,comma separated)> --silent


MySQL command myisamchk


    myisamchk --force --fast --update-state -O key_buffer=128M -O sort_buffer=128M -O  
    read_buffer=1M -O write_buffer=2M /usr/local/mysql/data/s_mon/*.MYI 2>&1 > myisamchk.log


  myisamchk: warning: Table  is marked as crashed and last repair failed 
  myisamchk: warning: 1 clients is using or hasn't closed the table properly 
  myisamchk: warning: Size of indexfile is: 12240194560 Should be: 4986249216 
  myisamchk: warning: Size of datafile is: 7019888251 Should be: 6931236906

output in log is:


  [email protected]# cat myisamchk.log 
  Checking MyISAM? file: /usr/local/mysql/data/s_mon/component_data.MYI 
  Data records: 407719818 Deleted blocks: 0