miércoles, 20 de marzo de 2013

Encender / Apagar remotamente un PC (Shutdown / Wake On Lan)


Shutdown / Wake On Lan


¿Sabías que es posible encender / apagar un PC de manera remota? Efectivamente, esto es posible y es muy sencillo. 

Probado con Windows XP profesional 

Shutdown

Requisitos

Es necesario que estés en la misma red de área local (LAN) que el PC objetivo, es decir el que deseas apagar de manera remota. Además debes saber el nombre de usuario y la contraseña de una sesión del PC objetivo. 

Puerto 445

Lo primero que debes hacer es comprobar que el puerto TCP 445 esté abierto en el cortafuegos de Windows del PC objetivo. 
Para ello, haz lo siguiente:
  • Dirígete a Inicio > Panel de control: Centro de seguridad
  • Haz clic en Cortafuegos de Windows luego dirígete a la pestaña Excepciones
  • Normalmente aparece una línea "Compartir archivos e impresoras", marca la casilla y haz clic en "Aceptar"
  • Si no te aparece la línea "Compartir archivos e impresoras", haz clic en "Agregar un puerto..." y selecciona el puerto 445 TCP
  • Luego dirígete a Inicio > Panel de control: Sistema en la pestaña "Uso de manera remota". Marca la casilla "Autorizar a los usuarios a conectarse de manera remota a este PC"

Comando

net use

Para obtener los privilegios necesarios para poder ejecutar un comando shutdown en el PC objetivo, debes ejecutar el comando net use. Es necesario obtener la dirección de la máquina objetivo, lo necesitaremos para ejecutar el comando. Para ello:
  • Dirígete a Inicio > Ejecutar (o presiona las teclas Windows + R)
  • Escribe cmd luego haz clic en Aceptar
  • Aparece una ventana DOS, escribe: net use \\ip_máquina_objetivo
  • Ingresa el nombre de usuario de una sesión de la maquina objetivo. Luego la contraseña
  • Aparecerá un mensaje indicando que el comando se ha terminado correctamente

shutdown

Ahora podemos pasar al comando en sí mismo. 
El comando es de este tipo: shutdown -s -f -t 30 - m \\192.168.3.4
  • -s: Apaga el PC
  • -f: Fuerza el cierre de las aplicaciones que se están ejecutando
  • -t xx: Define una cuenta en segundos
  • -m \\xxx.xxx.xxx.xxx: Precisa la dirección IP de la maquina objetivo.


Interfaz gráfica disponible ejecutando: shutdown -i
  • Para obtener ayuda sobre este comando, ejecuta shutdown /?

Además existen muchos programas que realizan lo mismo. 
Si todo se llevo a cabo correctamente, el PC objetivo recibirá un mensaje indicando el cierre del sistema. 

WakeOnLan

  • El Wake On Lan como su nombre lo indica, consisten en encender un ordenador de manera remota a través de la red, enviando un Magic Packet a la tarjeta de red del ordenador objetivo.
  • Importante: no todas las tarjetas de red ni las BIOS son compatibles con la recepción de los Magic Packet.

Requisitos

Para realizar esta operación es necesario que el PC de origen se encuentre en la misma red de area local (LAN) que el ordenador objetivo (el que quieres encender de manera remota) 
También es necesario conocer la dirección física (MAC) y la dirección IP del ordenador objetivo. 

MAC & IP

Lo primero que debes hacer es conseguir la dirección IP y la dirección MAC del ordenador objetivo:
  • Dirígete a Inicio > Ejecutar o presiona simultáneamente la tecla de Windows + R
  • Escribe cmd y haz clic en Aceptar
  • En la ventana DOS que aparece, escribe ipconfig/all

  • Toma nota de la dirección física (MAC) y la dirección IP

Tarjeta de red

Para ver si tu tarjeta de red es compatible, sigue estos pasos:
  • Haz clic derecho sobre Equipo y selecciona Administrar
  • Entra a Administrador de dispositivos > Adaptadores de red
  • Haz clic derecho sobre tu tarjeta de red y selecciona "Propiedades"
  • Una vez en Propiedades, debes buscar las palabras "Magic Packet", "Wake On Magic Packet", "Wake On Lan". Comprueba que todas las opciones estén activadas.
  • Si no encuentras estas opciones, quizás necesites actualizar tu tarjeta de red. Dirígete a la página del fabricante de la tarjeta.
  • Reinicia el ordenador objetivo.

BIOS


Para ver si tu BIOS es compatible, haz lo siguiente:
  • Reinicia el PC y entra a la BIOS presionando la tecla necesaria según la BIOS (ESC, F2, F5, F12, DEL)
  • Una vez en la BIOS, entra a las opciones de alimentación (POWER) y activa la opción Wake-on-Lan, o similar.

Cortafuegos

Abre el puerto 8900 del mismo modo que el puerto 445. 

WOL

  • Lo primero que debes hacer es descargar en el PC de origen, un pequeño programa Wake-on-Lan (WOL) de aquí
  • Esta es su interfaz:

  • Rellena los campos con la información obtenida más arriba
    • Mac Adress: dirección MAC (de la máquina objetivo)
    • Internet Adress: dirección IP local (de la máquina objetivo)
    • Subnet Mask: 255.255.255.255
    • Send Options: Local Subnet
    • Remote Port Number: 8900
  • Haz clic en el botón Wake Me Up


Una vez recibido el paquete, el PC objetivo debería encenderse. 

Desde Internet

En teoría, es posible encender el PC desde Internet, tan solo hay que configurar el router para redirigir un paquete UDP de un puerto especifico a todos los PCs de la red. En la práctica, solo es posible en algunos routers. Si envías el magic packet a tu dirección IP publica y al puerto correcto mediante el programa mencionado más arriba, tu PC se encenderá. Una sola configuración del router servirá para todos los PCs, pero cada PC será encendido independientemente de los otros, gracias a su magic packet personalizado. 

Por teléfono

Si deseas encender tu PC sin que te encuentres en casa, necesitarás un modem RTC externo sobre puerto serie RS-232 (un poco antiguo). Conecta el modem a tu PC, y activa la opción de tu BIOS "wake on modem ring" . De este modo, cuando el modem esté encendido, si tu teléfono suena, tu PC se encenderá...Este modem se conecta muy bien en la línea telefónica IP del router, tu teléfono deberá ser conectado en paralelo al modem. 

El inconveniente es que tu PC se encenderá (si el modem está encendido) a cada llamada telefónica...Personalmente yo ejecuto el comando siguiente en "Inicio > Ejecutar": 
shutdown -s -t 300 que apaga el PC al cabo de 5 minutos. Un acceso directo del comando shutdown -aen el escritorio permite anular el apagado cuando estás delante del PC. El comando de anulación puede ser lanzado de manera remota mediante VNC, un script PHP (exec), o cualquier otro método de ejecución de código de manera remota.

message archiving broken in 3.8.0

http://community.igniterealtime.org/thread/49324

martes, 19 de marzo de 2013

How can I force Ubuntu to boot on a stuck boot menu?


he answer to this one can be found in the grub file /etc/grub.d/00_header
make_timeout ()
{
    cat << EOF
if [ "\${recordfail}" = 1 ]; then
  set timeout=-1
else
  set timeout=${2}
fi
EOF
}
Setting the timeout value to -1 will stop the count down. Change the value to a value > 0 i.e. set timeout=10
this section of the file would look like
make_timeout ()
{
    cat << EOF
if [ "\${recordfail}" = 1 ]; then
  set timeout=10
else
  set timeout=${2}
fi
EOF
}
Then run
sudo update-grub2

jueves, 14 de marzo de 2013

How To Install And Configure SAMBA In Debian Squeeze


If you want to share files between your Debian and Windows computers, your best option is to use Samba file sharing.debian
Samba is a free software re-implementation of SMB/CIFS networking protocol, originally developed by Australian Andrew Tridgell. As of version 3, Samba provides file and print services for various Microsoft Windows clients and
can integrate with a Windows Server domain, either as a Primary Domain Controller (PDC) or as a domain member. It can also be part of an Active Directory domain.Samba runs on most Unix and Unix-like systems, such as Linux, Solaris, AIX and the BSD variants, including Apple’s Mac OS X Server (which was added to the Mac OS X client in version 10.2). Samba is standard on nearly all distributions of Linux and is commonly included as a basic system service on other Unix-based operating systems as well. Samba is released under the GNU General Public License. The nameSamba comes from SMB (Server Message Block), the name of the standard protocol used by the Microsoft Windows network file system.  (Wikipedia)
1-Specify  the  Samba Server
lets give my example server with IP 192.168.58.142

2- Install Samba
open  terminal and  install samba package and dependencies
$sudo apt-get install libcupsys2 samba samba-common
You will see the following questions:
Workgroup/Domain Name: <– WORKGROUP
Enter a workgroup name
Edit the smb.conf file using the command:
vi /etc/samba/smb.conf
Now activate  the  line security = user
[...]
# “security = user” is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html
# in the samba-doc package for details.
security = user
[...]
This enables Linux system users to log in to the Samba server.
save , exit and restart Samba:
/etc/init.d/samba restart

3- Add the Samba Shares
This will add a share that will be accessible from  all users.
Create the directory for sharing the files and change the group to the users group:
mkdir -p /home/samba-share/allusers
chown -R root:users /home/samba-share/allusers/
chmod -R ug+rwx,o+rx-w /home/samba-share/allusers/
At the end of the file /etc/samba/smb.conf add the following lines:
First open the smb.conf file using the command:
vi /etc/samba/smb.conf
and add:
[allusers]
comment = All Users
path = /home/samba-share/allusers
valid users = @users
force group = users
create mask = 0660
directory mask = 0771
writable = yes
If you want all users to be able to read and write to their home directories via Samba, add the following lines to /etc/samba/smb.conf:
[...]
[homes]
comment = Home Directories
browseable = no
valid users = @users
writable = yes
create mask = 0700
directory mask = 0700
save and restart Samba:
/etc/init.d/samba restart

Dont  forget  to set  read only  to  noin the config file
# By default, the home directories are exported read-only. Change the# next parameter to 'no' if you want to be able to write to them. read only = no
4 Add and manage the Users
In this example, I will add a user named tom. You can add as many users as you need in the same way, just replace the username tom with the desired username in the commands.
useradd  samba-user -m -G users
Set a password for samba-user in the Linux system .
-> Enter the password for the new user.
root@unixmen-debian6:~# passwd samba-userOutputEnter new UNIX password: Retype new UNIX password: 
Now add the user to the Samba user database:
root@unixmen-debian6:~# smbpasswd -a samba-userOutputNew SMB password:Retype new SMB password:Added user samba-user.root@unixmen-debian6:~# 
Now you should be able to log in from your Windows workstation with the file explorer (address is 192.168.58.142  or 192.168.58.142samba-user  for samba-user  home directory)
login to the samba server
login to you home  directory
For questions please refer to our Q/A forum at : http://ask.unixmen.com

miércoles, 27 de febrero de 2013

Zimbra Monitoring Incoming and Outgoing mails

Edit main.cf

 [root@map007]# vim /opt/zimbra/postfix/conf/main.cf

Add following line to get a bcc copy to your email id when some one send a mail :-

 sender_bcc_maps = hash:/opt/zimbra/conf/sender_bcc

Add following line to get a bcc copy to your email id when some one receive a mail :-

 recipient_bcc_maps = hash:/opt/zimbra/conf/recipient_bcc

Create two files in /opt/zimbra/conf directory

 touch /opt/zimbra/conf/sender_bcc
 touch /opt/zimbra/conf/recipient_bcc
 chown zimbra.zimbra /opt/zimbra/conf/sender_bcc
 chown zimbra.zimbra /opt/zimbra/conf/recipient_bcc

Edit these files and add entry like this :-
 support@efensys.com sandeep@efensys.com

After this I will get in/out mail’s copy of support@efensys.com email account to sandeep@efensys.com email id.

 As zimbra user, run following commands :-

 su - zimbra
 postmap /opt/zimbra/conf/sender_bcc
 postmap /opt/zimbra/conf/recipient_bcc
 postfix reload


-------------------------------------------------------------------------------------------

Login to terminal and run these command as zimbra user
sudo su
su – zimbra
Edit postfox config file
nano /opt/zimbra/postfix/conf/main.cf
Below last line of the main.cf add the following line
always_bcc = inoutmails@example.com
Reload postfix
postfix reload

martes, 12 de febrero de 2013

Change all file permissions to 644 and all folder permissions to 755 recursively

find . -type f -exec chmod 644 {} \+

find . -type d -exec chmod 755 {} \+





find . -type d -perm 777 -exec chmod 755 {} \; (for changing the directory permission)
find . -type f -perm 777 -exec chmod 644 {} \; (for changing the file permission)

domingo, 10 de febrero de 2013

How to Create a VPN Server on Ubuntu 12.04


pt-get update
apt-get install openvpn openssl
cd /etc/openvpn
cp -r /usr/share/doc/openvpn/examples/easy-rsa/2.0 ./easy-rsa
apt-get install nano
nano easy-rsa/vars
change
export EASY_RSA=”`pwd`”
to
export EASY_RSA=”/etc/openvpn/easy-rsa”
. ./easy-rsa/vars
./easy-rsa/clean-all
cd easy-rsa
ln -s openssl-1.0.0.cnf openssl.cnf
cd ..
./easy-rsa/build-ca OpenVPN
./easy-rsa/build-key-server server
./easy-rsa/build-key client1
./easy-rsa/build-dh
nano openvpn.conf
begin openvpn.conf contents – copy below this line
dev tun
proto udp
port 1194
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/server.crt
key /etc/openvpn/easy-rsa/keys/server.key
dh /etc/openvpn/easy-rsa/keys/dh1024.pem
user nobody
group nogroup
server 10.8.0.0 255.255.255.0
persist-key
persist-tun
status /var/log/openvpn-status.log
verb 3
client-to-client
push “redirect-gateway def1″
#set the dns servers
push “dhcp-option DNS 8.8.8.8″
push “dhcp-option DNS 8.8.4.4″
log-append /var/log/openvpn
comp-lzo
end openvpn.conf contents – copy above this line
echo 1 > /proc/sys/net/ipv4/ip_forward
do “ifconfig” to get adapter name and ipaddress (venet0 was mine since my vps host is using openvz)
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o venet0 -j SNAT --to YOUR.VPS.IP
cd ..
nano sysctl.conf
un-comment (remove the #) from the line containing #net.ipv4.ip_forward=1
cd ..
/etc/init.d/openvpn start
begin newvpn.ovpn contents – copy below this line
dev tun
client
proto udp
remote YOUR.VPS.IP 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert client1.crt
key client1.key
comp-lzo
verb 3
end newvpn.ovpn contents – copy above this line
The software I download the files with is called WinSCP. It allows you to transfer files via SSH. This is useful if you do not have an ftp or http server running.