Buscar este blog

viernes, 10 de abril de 2015

Conectar a MSSQL desde Linux CentOS 6.5

Desactivar SElinux
instalar apache:
yum install php apr  apr-util apr-util-ldap  httpd httpd-tools mailcap php-cli php-common php-mbstring
yum install epel-release
sino
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -Uvh epel-release-6*.rpm

yum install php-pdo php-mssql php-odbc

jueves, 9 de abril de 2015

Comandos para iptables in centos 6

agregar puerto 443 in rackspace
iptables -A INPUT -p tcp -m conntrack --ctstate NEW -m tcp --dport 443 -j ACCEPT

comando para guardar
service iptables save

comando para reinicia
service iptables restart

Comando para cargar un archivo de reglas
iptables-restore file   ó
iptables-restore < file

Comando para guardar
service iptables save ó
iptables-save > file

luego restart

lunes, 30 de marzo de 2015

Custom android driver for devices

CUSTOM MADE DRIVER FOR ANDROID DEVICES ON WINDOWS

You need to modify 3 things in order to make Google USB driver work for any android phone on any Windows:
1-modify android_winusb.inf file.
2- Digitally sign the modified driver
3- modify adb
and here are the details:
1-modify android_winusb.inf
the format to add is:
    ;Comment usually the device name
    %SingleAdbInterface%        = USB_Install, USB\; here you put VID and PID
    %CompositeAdbInterface%        = USB_Install, USB\; same as above but add the MI
before i go on, vid is the usb vendor id; it doesn’t have to be the same for the same Device OEM: for example: MSI gets usb chip in MSI enjoy tablet from a company and usb chip in MSI enjoy plus tablets in another company (rockchip).
How to get the vid and pid : they are in drivers you are merging; but if you don’t have a driver for the device you can get it by opening device manager; then right-click the device – select properties-in new dialog go to Details tab >in property drop menu select hardware ids. for example you see something like:
Image
    USB\VID_2207&PID_0000&REV_0222&MI_01
    USB\VID_2207&PID_0000&MI_01
take this value for composite adb device and remove MI for single adb device, you get
    ;MSI WindPad Enjoy 7 plus
    %SingleAdbInterface%        = USB_Install, USB\VID_2207&PID_0000
    %CompositeAdbInterface%     = USB_Install, USB\VID_2207&PID_0000&REV_0222&MI_01
    ;
copy this 2 line TWICE , once to  [Google.NTx86] section and another to [Google.NTamd64] section
REPEAT for every device you want to support
Now an optional edit for [Strings] Section: edit
    [Strings]
    ProviderName                = “Google, Inc.”
    SingleAdbInterface          = “Android ADB Interface”
    CompositeAdbInterface       = “Android Composite ADB Interface”
    SingleBootLoaderInterface   = “Android Bootloader Interface”
    WinUSB_SvcDesc              = “Android USB Driver”
    DISK_NAME                   = “Android WinUsb installation disk”
    ClassName                   = “Android Device”
To:
    [Strings]
    ProviderName                = “Google, Inc.”
    SingleAdbInterface          = “MSI ADB Interface”
    CompositeAdbInterface       = “MSI Composite ADB Interface”
    SingleBootLoaderInterface   = “MSI Bootloader Interface”
    WinUSB_SvcDesc              = “MSI USB Driver”
    DISK_NAME                   = “MSI WinUsb installation disk”
    ClassName                   = “MSI Tablet”
2- Sign the driver:
Although the original google usb driver was signed by google , modifying android_winusb.inf will prevent installing it on windows 8 showning an error message
Image
    The hash file is not present in the specified catalog file. The file is likely corrupt o the    victim of tampering.
This is only in Windows 8. Windows 7 or earlier do not show this error message. You have to regenerate catalog file (probably with Windows SDK) and sign
Workaround: A workaround for internal tesing is to diable windows signature verification : either temporarily or permanently:
temporarily:
Go to left upper or lower corner of screen to open charms bar and click settings charm.
choose Change PC settings
choose General
Scroll down, and click ‘Restart now’ under ‘Advanced startup’.
Click ‘Troubleshoot’.
Click ‘Advanced Options’
Click ‘Windows Startup Settings’
Click Restart.
or
run cmd
 and type:
shutdown -o -r -t 0
then after restarting choose  ‘Disable driver signature enforcement‘  from the list . install your driver before restarting.
Permanently:
press Window+Q
search for cmd
right click cmd
choose run as administrator from action bar
type in cmd:
    bcdedit -set loadoptions DISABLE_INTEGRITY_CHECKS
    bcdedit -set TESTSIGNING ON
3- modify adb:
a bug in adb make it doesn’t connect to some device vendors. add usb vendor id to it and recompile. modified ad are available:
Workaround:
in the command line:
echo 0x0e79 >> “%USERPROFILE%\.android\adb_usb.ini
this adds the vendor id to a file named adb_usb.ini in the user files
where 0e79 is the usb vendor id

sábado, 20 de diciembre de 2014

Tuning Mod Pagespeed

# Image Filters
ModPagespeedEnableFilters rewrite_images,insert_image_dimensions,inline_images,inline_preview_images,sprite_images,lazyload_images,convert_jpeg_to_progressive,jpeg_subsampling

# CSS Filters
ModPagespeedEnableFilters rewrite_css,move_css_above_scripts,combine_css,inline_css,flatten_css_imports,prioritize_critical_css,rewrite_style_attributes

# JS Filters
ModPagespeedEnableFilters rewrite_javascript,canonicalize_javascript_libraries,inline_javascript

# Misc Filters
ModPagespeedEnableFilters collapse_whitespace,trim_urls,remove_quotes,insert_dns_prefetch,extend_cache,inline_import_to_link

ModPagespeedEnableFilters prioritize_critical_css
ModPagespeedEnableFilters convert_jpeg_to_webp
ModPagespeedEnableFilters lazyload_images,inline_preview_images
ModPagespeedUseExperimentalJsMinifier on

martes, 11 de marzo de 2014

FTP pasivo in plesk panel


.....
.....
PassivePorts 57000 58000
# /sbin/modprobe ip_conntrack_ftp
# lsmod | grep conntrack_ftp
nf_conntrack_ftp       13696  0
nf_conntrack           61684  1 nf_conntrack_ftp
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
# /sbin/modprobe ip_nat_ftp

To keep the changes after the system boot, the modules should be added into /etc/sysconfig/iptables-config, toIPTABLES_MODULES line (space-separated).

lunes, 24 de febrero de 2014

Instalar DKIM in CentOS 6 con Plesk Panel

Esta semana tuve la oportunidad de asumir el reto de instalar opendkim en centos 6 con plesk para poder firmar nuestros correos y asi llegar a bandeja. Eso es lo que usan ahora las empresas dedicadas al negocio de envio de email como servicio por ejemplo Amazon SES y Mailgun de Rackspace, estos dos son muy buenos ejemplos. Pero ahora la idea es hacer lo mismo en nuestros propios servidores.

http://www.rosehosting.com/blog/how-to-install-and-integrate-opendkim-with-postfix-on-a-centos-6-vps/
http://blog.matoski.com/articles/spf-dk-dkim-plesk-debian/
http://stevejenkins.com/blog/2010/09/how-to-get-dkim-domainkeys-identified-mail-working-on-centos-5-5-and-postfix-using-opendkim/
## wget -P /tmp http://mirror.pnl.gov/epel/6/i386/epel-release-6-8.noarch.rpm
## rpm -Uvh /tmp/epel-release-6-8.noarch.rpm
## rm -f /tmp/epel-release-6-8.noarch.rpm
Install the package using yum:
## yum install opendkim

Despues de haber instalado open dkim hacemos lo siguiente:

si no esta creada la carpeta /etc/opendkim/keys la creamos sino omitimos el primer comando:

mkdir -pv /etc/opendkim/keys chown -Rv opendkim:opendkim /etc/opendkim chmod go-rwx /etc/opendkim/*

Luego creamos una carpeta con el dominio y generamos la firma digital y asignamos permisos

mkdir -p /etc/opendkim/keys/myserverplace.de cd /etc/opendkim/keys/myserverplace.de opendkim-genkey -d myserverplace.de -s mail chown -Rv opendkim:opendkim /etc/opendkim/keys/myserverplace.de chmod -v u=rw,go-rwx *

Luego asignar permisos 644 a Trustedhost,SigninTable y Keytable
Luego asignar permisos 700 a la carpeta y subcarpetas de keys

Luego editar nuestro archivo Trustedhost y poner las ips o dominios permitidos
En el archivo Keytable poner lo siguiente
mail._domainkey.linkwebservices.com linkwebservices.com:mail:/etc/opendkim/keys/linkwebservices.com/mail.private

En el archivo Signingtable poner lo siguiente:
*@linkwebservices.com mail._domainkey.linkwebservices.com

Una vez que hagamos esto ir a la configuracion dns de nuestro dominio y agregar un registro txt llamado _mail.domainkey debe quedar como lo siguiente :
mail._domainkey.linkwebservices.com  TXT  v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC7KtU5uKKA5GJsghjQ/FzFcY0ryDsmoUMcICR2uie22gJqZ016gIHxwSWMbMjz/EliHTMrpJPMmMGQ0YU9NnuBlCWbM8XyVSrj7QWFVvbF/tXBp3COatoOWw3qVfzSBZ4NwaZXLVdU/c5jZJiyWpKgJJCxHTxkoXWDvgcXmr4LeQIDAQAB

Pueden testear su registro dns con estas dos herramientas.


Los siguientes pasos son configurar nuestro archivo /etc/opendkim.conf y /etc/postfix/main.cf

El contenido del primer archivo debe quedar asi:

##
## opendkim.conf -- configuration file for OpenDKIM filter
##
Canonicalization        relaxed/relaxed
ExternalIgnoreList      refile:/etc/opendkim/TrustedHosts
InternalHosts           refile:/etc/opendkim/TrustedHosts
KeyTable                refile:/etc/opendkim/KeyTable
LogWhy                  Yes
MinimumKeyBits          1024
Mode                    sv
PidFile                 /var/run/opendkim/opendkim.pid
SigningTable            refile:/etc/opendkim/SigningTable
Socket                  inet:8891@127.0.0.1
Syslog                  Yes
SyslogSuccess           Yes
TemporaryDirectory      /var/tmp
UMask                   022
UserID                  opendkim:opendkim

Y en el segundo archivo añadimos al final lo siguiente:
# OpenDKIM
#milter_protocol = 6
smtpd_milters = , inet:127.0.0.1:8891, inet:127.0.0.1:12768
non_smtpd_milters = $smtpd_milters
milter_default_action = accept

Comentamos la linea del protocolo porque no me funciono a pesar de que en el blog de matoski de donde obtuve información decia que si le funcionó sin nigun problema. Igual pueden probar de las dos formas, ya lo dejo a criterio de ustedes.

Finalmente reiniciamos opendkim y postfix
service opendkim restart
service postfix restart

con hacer esto deberia de terminar todo, pero no es asi, por alguna razon, cuando reiniciamos opendlim, genera un certificado por defecto el cual resetea los permisos de nuestra carpeta keys, hay que cerciorarnos de que la carpeta keys tenga los permisos correspondientes que señalamos arriba

chown -R 700 keys/
 chown -R opendkim:opendkim keys/

volvemos a reiniciar los servicios

service opendkim restart
service postfix restart

ahora si ya esta todo configurado correctamente :D

no olvidar setear opendkim como servicio de inicio para que se inicie cuando bootee el sistema:
chkconfig opendkim on

Con eso deberia poder estar firmando sus correos, y mas un spf valido deberian estar llegando a bandeja de entrada en gmail y outlook y otros servicios que usen DKIM, ojo el ip tambien debe estar limpio, no tener requisitorias de haber sido usado para enviar spam, porque por ejemplo yahoo bloquea ips que han tenido un historial malo, y asi usen dkim, los seguira rechazando, ojo con eso.
Este tutorial se puede aplicar a aquellas direcciones ips que sabiendo que estan limpias, no llegan a bandeja de entrada y lo envian a la carpeta de spam. Con esto deberian los emails llegar a bandeja. Al menos yo lo comprobe con el dominio que hice las pruebas y todo fue exitoso. 
Pueden enviar un email a estas direcciones para obtener un reporte de spf, domainkeys y DKIM
  • check-auth@verifier.port25.com
  • AAAA3QcKCQwA@appmaildev.com

Saludos.



sábado, 25 de enero de 2014

¿Problemas con el cron en Plesk?

Cuando no se ejecuten las tareas programadas en linux, es porque por defecto no tienen acceso a la shell /bin/sh.
Para permitir el acceso ejecuten esta sentencia.
/usr/local/psa/bin/server_pref -u -crontab-secure-shell "/bin/sh"
para quitar el permiso se ejecutar lo siguiente
/usr/local/psa/bin/server_pref -u -crontab-secure-shell ""