viernes, 7 de agosto de 2009

Backup and restore Putty configuration

1. Click Start->Run and type "regedit" in the "Open" dialog. Click "Ok"

2. Press "Ctrl+F" to bring up the Find dialog. Enter the name of the key, "SimonTatham" in the "Find What" field, and make sure only "Keys" is checked in the "Look At" section of the dialog. Finally, click "Find Next".

3. Click File->Export. Give your file an appropriate name like, "putty.reg" and click "Save".

4. We're done! Save the putty.reg file somewhere safe. The file doesn't contain any passwords or actual SSH key values so, it's relatively safe from prying eyes. Still, it does contain your configuration and that kind of data is a private matter.

5. To import your saved PuTTy configuration on any other Windows computer simply copy your exported registry key, right click on the file and click "Merge".

Windows will ask you for confirmation that you want to import this set of registry values. We know this file is safe, because we created it but, you should never import registry information from an unknown source.

lunes, 3 de agosto de 2009

OpenVPN && VPN OpenSolaris 11.06

Como Instalar OpenVPN en OpenSolaris x86 b79 32/64 bits
Este es el proceso empleado para instalar openvpn OpenSolaris 11.06

Primero debemos instalar las dependencias:

pkg install SUNWgcc


Descargar las fuentes de tun/tap.

cd /usr/local/src
wget http://www.whiteboard.ne.jp/~admin2/tuntap/source/tuntap/tuntap.tar.gz
tar xvfz tuntap.tar.gz
chown -R root:root tuntap
cd tuntap

Cambiar la configuracion del Makefile.in

LDFLAGS = -melf_x86_64
...
modules: tun.o tap.o
$(LD) $(LDFLAGS) -r -o tun tun.o
$(LD) $(LDFLAGS) -r -o tap tap.o


./configure
make

Configurar tun.
# devfsadm –i tun

Validar los mensajes del syslog.

#dmesg

Instalar LZO para compresion en Tiempo Real:

# wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.03.tar.gz

# gzcat lzo-2.03.tar.gz | tar xvf lzo-2.03.tar.gz

# gzcat lzo-2.03.tar.gz | tar xvf -

# cd lzo-2.03

# ./configure

# make

# make install



Instalar OpenVPN.

wget http://openvpn.net/release/openvpn-2.0.9.tar.gz
# gzcat openvpn-2.0.9.tar.gz | tar xvf –
# cd openvpn-2.0.9
##### ./configure --disable-lzo  # Para deshabilitar compresion de lzo
# ./configure --with-lzo-lib=/usr/local/lib

# make
# make install
Crear un archivo de start/stop para subir el servicio automaticamente:

#!/bin/bash
case "$1" in
'start')
echo "Starting Openvpn"
nohup /usr/local/sbin/openvpn --config /etc/openvpn/pegasus.conf --writepid /var/run/openvpnd.pid &
;;

'stop')
echo "Stoping Openvpn"
if [ -f /var/run/openvpnd.pid ]; then
PID=`cat /var/run/openvpnd.pid`
kill -9 $PID
ifconfig tun0 unplumb
fi
;;

*)
echo "Usage: $0 { stop | start }"
exit 1
;;
esac

Crear el archivo de configuracion similiar a:

client
dev tun
# tun-mtu 1500
tun-mtu 1434
proto udp
#remote 201.228.144.5 1194
remote 10.201.136.36 1194

ca /etc/openvpn/ca.crt
cert /etc/openvpn/pegasus.crt
key /etc/openvpn/pegasus.key
ping 30
ping-exit 66
verb 6
mute 20
comp-lzo

martes, 30 de junio de 2009

martes, 6 de enero de 2009

create iso image in solaris

dd if=/dev/dsk/c3t0d0s2 of=eisdvd.iso bs=512

jueves, 11 de diciembre de 2008

backup restore mysql sugar crm

backup:

mysqldump -u root -ppassw0rd sugarcrm > \
backup/sugarcrm_11-12-2008-01_dump.sql

mysqldump -u root -ppassw0rd sugarcrm > \ backup/sugarcrm_11-12-2008-02_dump.sql

mysqldump -u root -ppassw0rd --all-databases > \ backup/all-database_11-12-2008-01.sql

mysqldump -u root -ppassw0rd --all-databases > \ backup/all-database_11-12-2008-02.sql

Restore:

mysql -u root -peLaStIx.2oo7 sugarcrm < \ backup/sugarcrm_11-12-2008-02_dump.sql

lunes, 8 de diciembre de 2008

Remote Access to Mysql

grant select on *.* to 'root'@192.168.100.54 identified by 'eLaStIx.2oo7';
grant update on *.* to 'root'@192.168.100.54 identified by 'eLaStIx.2oo7';
grant create on *.* to 'root'@192.168.100.54 identified by 'eLaStIx.2oo7';
flush privileges;

viernes, 28 de noviembre de 2008

multi-boot solaris x86

#---------- ADDED BY BOOTADM - DO NOT EDIT ----------
# Solaris 32bits
title Solaris 10 10/08 s10x_u6wos_07b X86 32b
findroot (rootfs0,3,a)
kernel /boot/multiboot kernel/unix
module /platform/i86pc/boot_archive
#---------------------END BOOTADM--------------------
title Solaris 10 10/08 s10x_u6wos_07b X86 64b
findroot (rootfs0,3,a)
kernel /platform/i86pc/multiboot
module /platform/i86pc/boot_archive
#---------------------END BOOTADM--------------------
#---------- ADDED BY BOOTADM - DO NOT EDIT ----------
title Solaris failsafe
findroot (rootfs0,3,a)
kernel /boot/multiboot kernel/unix -s
module /boot/x86.miniroot-safe
#---------------------END BOOTADM--------------------

title Ubuntu 8.10, kernel 2.6.27-7-generic
root (hd0,0)
kernel /boot/vmlinuz-2.6.27-7-generic root=/dev/sda1 ro quiet splash
initrd /boot/initrd.img-2.6.27-7-generic

Procedure to add a swap file

a) Login as the root user

b) Type following command to create 512MB swap file (1024 * 512MB = 524288 block size):
# dd if=/dev/zero of=/swapfile1 bs=1024 count=524288

c) Set up a Linux swap area:
# mkswap /swapfile1

d) Activate /swapfile1 swap space immediately:
# swapon /swapfile1

e) To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:
# vi /etc/fstab

Append following line:
/swapfile1 swap swap defaults 0 0

So next time Linux comes up after reboot, it enables the new swap file for you automatically.

g) How do I verify swap is activated or not?
Simply use free command:
$ free -m

profile solaris 10

PATH=$PATH:/usr/sbin:/opt/csw/bin:/usr/sfw/bin:/usr/ccs/bin:/usr/local/sbin:/usr/local/bin
LIBPATH=$LIBPATH:/opt/csw/lib:/usr/sfw/lib
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIBPATH
export PATH LD_LIBRARY_PATH LIBPATH

miércoles, 19 de noviembre de 2008

zone clone

# Bajar la zona que se desea clonar
zlogin CT1NSZSOPVA003 init 0

# Validar que la zona ya esta en shutdown
zoneadm list -cv

# Exportart la configuracion de la zona y salvarla con el nombre de la nueva zona que se desea crear
zonecfg -z CT1NSZSOPVA003 export -f /root/cfg/CT1LOGZSOPVA001.cfg

# Modificar parametros con el zonepath, Direcciones IP y demas que se requieran en la nueva zona.
vi /root/cfg/CT1LOGZSOPVA001.cfg

# Crear la nueva zona apartir de archivo de configuracion modificado.
zonecfg -z CT1LOGZSOPVA001 -f /root/cfg/CT1LOGZSOPVA001.cfg

# Clonar la zona
zoneadm -z CT1LOGZSOPVA001 clone CT1NSZSOPVA003

# Validar que la nueva zona esta en estado "Installed"
zoneadm list -cv

# Hacer boot de la nueva zona
zoneadm -z CT1LOGZSOPVA001 boot

# Validar que la nueva zona esta running
zoneadm list -cv

# Hacer la configuracion Inicial de la zona.
zlogin -C CT1LOGZSOPVA001

martes, 11 de noviembre de 2008

MP3 in Ubuntu

sudo apt-get install audacious

sábado, 8 de noviembre de 2008

File Descriptors

A file descriptor is a handle created by a process when a file is opened. There is a limit to the amount of file descriptors per process. The default Solaris file descriptor limit is 64.

If the file descriptor limit is exceeded for a process, you may see the following errors:

"Too Many Open Files"
"Err#24 EMFILE" (in truss output)

To display a process' current file descriptor limit, run /usr/proc/bin/pfiles pid | grep rlimit on Solaris systems.

Display system file descriptor settings:
ulimit -Hn (hard limit, cannot be exceeded)
ulimit -Sn / ulimit -n (soft limit may be increased to hard limit value)

Increasing file descriptor settings for child processes (example):
$ ulimit -Hn
1024
$ ulimit -Sn
64
$ ulimit -Sn 1024
$ ulimit -Sn
1024

Solaris kernel parameters:
rlim_fd_cur: soft limit

It may be dangerous to set this value higher than 256 due to limitations with the stdio library. If programs require more file descriptors, they should use setrlimit directly.

rlim_fd_max: hard limit

It may be dangerous to set this value higher than 1024 due to limitations with select. If programs require more file descriptors, they should use setrlimit directly.

To count number of open file descriptors:

#!/bin/bash
var=`ps -fea | grep named | grep -v pts | awk '{ print $2 }'`
for i in $var; do
npfiles=`/usr/proc/bin/pfiles -n $i | tail +3 | wc -l` ;
echo "Number of Open File Descriptors per named Process: PID=$i : Num OPFD=$npfiles";
done


http://www.princeton.edu/%7Eunix/Solaris/troubleshoot/filedesc.html



SOLUTION: Using FD_SETSIZE to allow application to use more than 1024 file descriptors

The application core dumped after attempting to access more file descriptors than allowed by the 32-bit library.

From the manpage for select(3C) :

"The default value for FD_SETSIZE (currently 1024) is larger than the default limit on the number of open files. To accommodate 32-bit applications that wish to use a larger number of open files with select(), it is possible to increase this size at compile time by providing a larger definition of FD_SETSIZE before the inclusion of.

The maximum supported size for FD_SETSIZE is 65536. The default value is already 65536 for 64-bit applications."

And from /usr/include/sys/select.h :

#ifndef FD_SETSIZE
#ifdef _LP64
#define FD_SETSIZE 65536
#else
#define FD_SETSIZE 1024
#endif /* _LP64 */
#elif FD_SETSIZE > 1024 && !defined(_LP64)
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname select select_large_fdset
#else /* __PRAGMA_REDEFINE_EXTNAME */
#define select select_large_fdset
#endif /* __PRAGMA_REDEFINE_EXTNAME */
#endif /* FD_SETSIZE */

On Solaris[TM] 7, 8, 9, and 10 one can over come the 1024 32-bit library file descriptors limit by redefining the maximum allowed library limit and recompiling the source code with the following lines added.

        #define FD_SETSIZE 65535
#include

The FD_SETSIZE is the library file descriptor limit. After adjusting the library limit, it is necessary to adjust the system limit of file descriptors. This can be done by adding the following lines to the etc/system file and then rebooting.

        set rlim_fd_cur 1024
set rlim_fd_max 65535

To adjust the current soft limit of allowable system file descriptors above 1024 for an application without adjusting the system soft limit, one should use the "ulimit -n [limit]" or "limit descriptors [limit]" commands before starting applications that require more than 1024 file descriptors.

The value can not exceed the maximum in the table below.

default soft limit | default hard limit | max for stdio | max for select()

Solaris[TM] 2.4-2.6 64 1024 256 1024

Solaris[TM] 7 (32-bit) 64 1024 256 65535 (with recompile)

Solaris[TM] 7 (64-bit) 64 1024 256 65535

Solaris[TM] 8 (32-bit) 256 1024 256 65535 (with recompile)

Solaris[TM] 8 (64-bit) 256 1024 256 65535

Solaris[TM] 9 (32-bit) 256 65535 256 65535 (with recompile)

Solaris[TM] 9 (64-bit) 256 65535 256 65535

Solaris[TM] 10 (32-bit) 256 65535 256 65535 (with recompile)

Solaris[TM] 10 (64-bit) 256 65535 256 65535

Please note that for applications that use the Berkeley stdio.h interface (i.e. fopen/fclose/fread/fwrite, etc), the maximum number of open file descriptors per process is 256.

With the exception of databases and WebServers, most applications never need more than 256 open file descriptors. Also starting with Solaris[TM] 7, the plimit(1) command can be used to adjust the soft and hard limits of a running process.

plimit -n ,

The poll() system call has the number of file descriptors being polled passed in as an argument, so it has none of the above limitations.

File Descriptors

A file descriptor is a handle created by a process when a file is opened. There is a limit to the amount of file descriptors per process. The default Solaris file descriptor limit is 64.

If the file descriptor limit is exceeded for a process, you may see the following errors:

"Too Many Open Files"
"Err#24 EMFILE" (in truss output)

To display a process' current file descriptor limit, run /usr/proc/bin/pfiles pid | grep rlimit on Solaris systems.

Display system file descriptor settings:
ulimit -Hn (hard limit, cannot be exceeded)
ulimit -Sn / ulimit -n (soft limit may be increased to hard limit value)

Increasing file descriptor settings for child processes (example):
$ ulimit -Hn
1024
$ ulimit -Sn
64
$ ulimit -Sn 1024
$ ulimit -Sn
1024

Solaris kernel parameters:
rlim_fd_cur: soft limit

It may be dangerous to set this value higher than 256 due to limitations with the stdio library. If programs require more file descriptors, they should use setrlimit directly.

rlim_fd_max: hard limit

It may be dangerous to set this value higher than 1024 due to limitations with select. If programs require more file descriptors, they should use setrlimit directly.

http://www.princeton.edu/%7Eunix/Solaris/troubleshoot/filedesc.html

miércoles, 29 de octubre de 2008

Enable Relay MTA JES

Para habilitar el relay en JES hacer:

Editar el archivo:
vi /jes/bin/SUNWmsgsr/config/mappings

Buscar en "INTERNAL_IP".

$(200.21.190.164/24) $Y
$(190.254.0.106/32) $Y
$(190.254.0.117/32) $Y
$(190.254.0.109/32) $Y
$(10.192.32.6/32) $Y
$(10.192.32.4/32) $Y
127.0.0.1 $Y
* $N

Luego reiniciar el demonio:

cd /jes/bin/SUNWmsgr/sbin
./stop-msg mta ; ./start-msg mta

sábado, 25 de octubre de 2008

IPS OpenSolaris

marco@pegasus:~$ pfexec pkg set-authority -O http://pkg.sunfreeware.com:9000 sunfreeware

marco@pegasus:~$ pfexec pkg set-authority -O http://blastwave.network.com:10000 blastwave

marco@pegasus:~$ pfexec pkg authority -H
blastwave http://blastwave.network.com:10000/
sunfreeware http://pkg.sunfreeware.com:9000/
opensolaris.org (preferred) http://pkg.opensolaris.org:80/


marco@pegasus:~$

lunes, 13 de octubre de 2008

tftp solaris 10

Validar si esta el servicio creado:

svcs | grep tf

# Crear el servicio.

vi /var/tmp/tftpd.conf

# Adicionar la siguente linea:

tftp dgram udp6 wait root /usr/sbin/in.tftpd in.tftpd -s /tftpboot

mkdir /tftpboot
chown root /tftpboot
chmod 755 /tftpboot

Validar que el puerto este definido para el tftp:

grep tf /etc/services

Importar el Servicio.

/usr/sbin/inetconv -i /var/tmp/tftpd.conf

# Validar que el servicio este online:

svcs -a |grep tftp

sábado, 11 de octubre de 2008

zonecfg

create
set zonepath=/zonas/testing
set autoboot=true

add net
set address=172.28.46.1/24
set physical=e1000g0
end

add fs
set dir=/mnt
set special=/dev/dsk/c0t0d0s7
set raw=/dev/rdsk/c0t0d0s2
set type=ufs
add options [logging]
end

add inherit-pkg-dir
set dir=/usr/sfw
end

add device
set match=/dev/sound/*
end

add attr
set name=comment
set type=string
set value="The work zone."
end

remove inherit-pkg-dir dir=/lib
remove inherit-pkg-dir dir=/platform
remove inherit-pkg-dir dir=/sbin
remove inherit-pkg-dir dir=/usr

verify
commit

ipmp solaris 10 8/07

ifconfig ce0 plumb
ifconfig ce1 plumb


ifconfig ce0 10.57.1.61 netmask 255.255.0.0 broadcast + group service0 up
ifconfig ce1 deprecated group service0 -failover standby up

*****/etc/hostname.ce0******
pegasus netmask 255.255.0.0 broadcast + group service0 up

*****/etc/hostname.ce1******
deprecated group service0 -failover standby up

jueves, 17 de julio de 2008

vi editor

EDITOR VI

ENTRADA AL EDITOR

$ vi Edita un fichero sin nombre.
$ vi NOMNUEVO Edita un fichero nuevo con nombre.
$ vi NOMVIEJO Edita un fichero ya existente.
$ vi nom1 nom2 Edita varios ficheros simultáneamente.
$ vi +n nomviejo Hará que n sea la línea actual cuando se edite el fichero.
$ vi +$ nomviejo Coloca el cursor al final del fichero.
$ vi +orden fich Hace que se ejecute la orden del editor antes de visualizar el fichero.
$vi +/palabra fich Situa el cursor, al editar “fich”, en la primera ocurrencia de la palabra
especificada del fichero.

ALMACENAR, MOVERSE Y ABANDONAR EL EDITOR

:w Salva el contenido del texto visualizado en pantalla.
:w nomfich Almacena el texto editado en un archivo con el nombre indicado.
:w>>nomfich Añade el texto editado al archivo ya existente especificado.
:q Salida del fichero editado. Requiere haber salvado previamente con :w las
modificaciones realizadas.
:q! Sale de la edición sin salvar el fichero editado.
:wq Salva el fichero editado y luego sale de VI.
ZZ Hace lo mismo que :wq.
:n Visualiza el siguiente fichero de la cola.
:r nomfich Añade el contenido de un fichero (nomfich) al texto editado, a partir de la
posición del cursor.
:rewind Visualiza el primer fichero de los editados.

MOVIMIENTOS DEL CURSOR

nh Mueve el cursor n caracteres hacia la izda.
n ^h Mueve el cursor n caracteres hacia la izda.
nl Mueve el cursor n caracteres hacia la dcha.
n Mueve el cursor n caracteres hacia la dcha.
nW Mueve el cursor n palabras hacia la dcha. y lo sitúa en el primer caracter
de la palabra (teniendo en cuenta que una palabra será una serie de
caracteres hasta un espacio en blanco).
nB Mueve el cursor n palabras hacia la izda. y lo sitúa en el primer caracter de
la palabra.
n Mueve el cursor n líneas hacia abajo y lo sitúa al comienzo de la línea.
nj Mueve el cursor n líneas hacia abajo y lo deja en la misma columna.
nk Mueve el cursor n líneas hacia arriba y lo deja en la misma columna.
G Mueve el cursor hasta el primer caracter de la última línea del fichero.
nG Mueve el cursor hasta el primer caracter de la enésima línea del fichero.
$ Mueve el cursor al último caracter de la línea actual.
n$ Mueve el cursor hasta el último caracter de la enésima línea del fichero.
0 Mueve el cursor al primer caracter de la línea.
H Mueve el cursor al principio de la pantalla.
L Mueve el cursor al final de la pantalla.
M Mueve el cursor hasta la mitad de la pantalla.
^f Hace subir la pantalla (scroll down) (PAGE UP).

MOVIMIENTOS DEL CURSOR

^b Hace bajar la pantalla (scroll up) (PAGE DOWN).
:nº Situa el cursor en la línea indicada.
:+nº Avanza el cursor n líneas hacia abajo a partir de la posición del cursor.
:-nº Retrocede el cursor n líneas hacia arriba desde la posición actual del
cursor.

BORRAR TEXTO

nx Borra n caracteres a partir de la posición actual del cursor.
ndW Borra n palabras de la derecha del cursor.
ndB Borra n palabras de la izquierda del cursor.
nS Borra el contenido de n líneas a partir del cursor.
n dd Borra n líneas enteras a partir de donde está el cursor.
D Borra el resto de la línea a partir de la posición del cursor.

AÑADIR TEXTO

a Añade texto después del cursor.
i Inserta texto antes del cursor.
A Añade texto al final de la actual línea.
I Inserta texto al principio de la actual línea.
o Abre una línea a continuación para insertar texto.
O Abre una línea encima de la actual para insertar texto.

COPIAR Y MOVER TEXTO

n r car Cambia los n primeros caracteres a partir del cursor por el caracter
especificado.
r Permite reemplazar el caracter actual por otro que se teclee.
R Permite entrar en modo sustitución de caracteres,permaneciendo sin variar
los caracteres de la línea que no se hayan sobreescrito.
C Lo mismo que el anterior, pero aquellos caracteres de la línea que no se
hayan sobreescrito se borrarán (el resto de la línea no cambiado se borra).
J Junta la línea actual con la siguiente eliminando el que las separa.
nY Almacena temporalmente en un espacio de memoria (buffer) n líneas
desde la posición actual del cursor.
P Inserta las líneas sacadas con Y, a partir de la línea actual.

RESTAURAR Y REPETIR CAMBIOS

. Repite el último cambio realizado.
u Restaura el último cambio realizado.

OPCIONES DE ENTORNO

: set nu Visualiza en la pantalla los números de líneas.
: set nonu Elimina de la pantalla los números de líneas.
: set list Hace que se visualicen los caracteres de control (tabuladores, retornos de
carro, etc.)
: set nolist Elimina la opción anterior.
: set wm=n Establece el retorno automático de línea en la columna 80-n. (Para ponerlo
en la 50 habría que poner n=30).
: set wm=0 Elimina el retorno de línea automático.

BUSQUEDA, SUSTITUCION Y ELIMINACION

:/argumento/ Busca, a partir de la siguiente línea a la actual, la primera ocurrencia del
argumento, y se situa el cursor al comienzo de la línea donde se encuentre
el argumento.
:/^argumento/ Busca la ocurrencia en el principio de las líneas.
:/argumento$/ Busca la ocurrencia al final de las líneas.
:g/arg/d Elimina todas las líneas que contienen el argumento.
:g/^$/d Elimina todas las líneas vacías.
:s/textant/textnue/ Sustituye el texto antiguo por el texto nuevo.
:g/textant/s//textnue/g Sustituye todas las ocurrencias de textoant por textonuevo.
:g/textant/s//textnue/gc Hace lo mismo que el anterior pero pidiendo confirmación. Se ha de
contestar y, en caso contrario no se sustituye.
:g/argumento/s/texto//g Borra el texto en todas las líneas que contengan el argumento. Si no se
pone texto se borra la línea completa.

ESCAPAR AL SHELL DESDE EL EDITOR

:! orden Abandona el vi momentáneamente para ejecutar la orden. Para volver al
editor basta teclear .
:sh Ejecuta un shell nuevo apartando el vi. Se vuelve con exit o <^d>.
:r !orden Lleva la salida standard de la orden al fichero.

viernes, 11 de julio de 2008

how to use find

find . -type f -exec grep -i ADMINPASS {} \;