Author: Oriol Rius

Extracting private and public keys from a p12 file

Reading time: 6 – 9 minutes

PKCS#12 is a container for storing many cryptography objects as a single file. It is commonly used to bundle a private key with its X.509 certificate or to bundle all the members of a chain of trust. This is a fast and simple summary about how to extract your keys from those kind of files:

#Private key:
openssl pkcs12 -in file_name.p12 -nocerts -out private.key
#Certificates:
openssl pkcs12 -in file_name.p12 -clcerts -nokeys -out public.crt

Recurrently I have to access to a usuful guide about those kind of openssl parameters, let me refer that guide:

The Most Common OpenSSL Commands (local copy)

Update 2016/09/19
Usefull links for SSL:

Avui fa 16 anys que vaig començar a escriure el blog

Reading time: 1 – 2 minutes

16th_anniversary

 

Feliç de recordar l’efemèride i de malgrat no tenir un blog molt prolífic poder explicar que he aconseguir mantenir l’hàbit d’anar compartint encara que fos en petites píldores alguns dels fets i coneixements que la vida m’ha anat permetent disfrutar. Des de l’arribada del Roc més que mai he hagut de tancar el meu “pipeline” de projectes però una cosa positiva és que t’acabes centrant en l’escència i en el que et fa disfrutar més. Per desgràcia no pots atendre moltes altres coses que sovint tornen en forma de records o pensaments, això si, t’adones que les coses que has permès que seguissin al teu costat tenen el millor gust que mai havien tingut.

Només puc dir-vos que la meva intenció és seguir buscant reconets i estones per seguir compartint-vos el que hem passa pel cap, mentrestant ús envio una abraçada molt forta.

GRÀCIES PER SEGUIR-ME!

Mikrotik as a PPTP server for Android

Reading time: 4 – 6 minutes

Two years ago I installed a Mikrotik Cloud Switch and lately I stoped my pfSense and I started using that switch as my network router, firewall and also as a switch. RouterOS is really powerful and allows to do a lot of things with that hardware. One of those things is set-up a VPN server based on PPTP. This is not the most secure way to create VPNs but usually the only requirement is a little bit of security on top of an IP over IP service that allows us to use local service when we’re in remote. In my case I have a lot of services in my LAN and I need some of them when I’m out of home specially I need to use them from my mobile phone.

Next steps describe how I set-up a PPTP server on my Mikrotik server allowing my Android 6 device (Huawei Mate 8) to connect to my home services through the VPN. Bellow you have a simple schema representing the schenario of the solution:

architecture

I’m only going to describe steps from the web console, of course, all those steps can be done using Winbox or the command line. To be honest I’m not used to RouterOS CLI but I think it’s not difficult to figure out the CLI commands to get the same result.

First step is set-up a pool of IP addresses to be assigned to the tunnel endpoints.

01-ip-pool

02-ip-pool

Thanks to an ARP proxy those IP addresses will be available like local IPs, this is transparent for the VPN configuration.

00-arp-proxy

configuration of connection profile is done inside “Profiles” tab:

05-profiles

first of all create a new profile called “default-encription”:

061-profiles

and another profile called “pptp-profile”:

06-profiles

“Secrets” tab is where you have to manage users, in my case only two users are created:

07-secrets

configuration details about my user are:

08-secrets

Inside PPP menu there is a button with a label “PPTP server” click there…

03-pptp-server

… and copy next settings:

04-pptp-server

Don’t forget to check that your PPTP port is accessible from your public IP address. Remember it’s 1723/TCP.

Android configuration is simple, first of all go to “settings” icon. Look for a “More” section bellow network options, and you’ll find VPN managment. Add a new connection, define a name, the type and the IP address and leave the rest by default. After that when you come back to VPN list you’ll find your new VPN in the list, click there and just set-up your PPTP credentials.

android

If you have some trouble the only thing that you can do is go to Mikrotik logs or start sniffing to figure out where is the problem. I had to do some tests before it was working but in the end everything was so simple like I explained here.

Good luck and enjoy it.

Thanks to next blog entries to inspire me:

 

 

Remove old kernels when there is no space in /boot

Reading time: 8 – 14 minutes

The first step is get some space in the partition “/boot” because without that it’s impossible to do anything.

So go to /boot and remove some “initrd” files as they are the biggest ones. A few of them will be enough.

After that a good point is to ensure there is no partial installation pending to finish:

apt-get -f install

Now it’s a good idea to purge all kernels except the running one:

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

To avoid that in future before filling the partition, it’s a good idea to install and run periodically: purge-old-kernels. Installation and example of use are:

# installation
apt-get install bikeshed
# keep three old kernels:
purge-old-kernels --keep 3
# if you want to put that in the crontab use that command
purge-old-kernels --keep 3 -qy

If you’re a Grub user don’t forget to run:

update-grub2

Personally I have a nightmare with that problem and Ubuntu, especially with version 12.04 which is installed in a lot of servers that I manage. I repeated the previous process a lot of times and in the end, I decided to document it because I always have to go to Google and find the proper steps to solve that problem.

Protecting your email with MXGuarddog

Reading time: 2 – 2 minutes

mxguarddogAfter using VMWare ESXi for a long time as a Hypervisor for my virtual servers I decided to stop paying OVH for that service and I migrated my virtual machines to VPS servers on OVH. At the end of the day only two VPS with a cost of 3€/month are enough and I can stop a 50€/month dedicated server.

The biggest challenge that I had to solve was migrate mail server to a new server. So far today I was using pfSense a firewall for my virtual servers. They were in a virtual network; pfSense anti-spam services and mail forwarding were enough to receive “cleaned” mail in my private mail server with Postfix and Dovecot.

New configuration is just a cheap VPS (1xCPU+2GB RAM+10GB SSD) with Ubuntu 16.04 and also with Postfix and Dovecot. But I decided to rent the anti-spam, anti-malware and anti-virus service to MX Guarddog. I discovered that service just surfing on the big G. Only 0.25 cents per account per month it’s a very good price and it does all the things that I need and much more. Configuration is really simple if you know what you are doing. They have a very good and simple control panel to manage the service. This is the perfect service to get what I need.

In the control panel you can do all that you need, manage mail accounts and domains. View quarantined mails and all required configurations and tests to validate everything is ready and also maintain white and black lists. We’ll see during next days if the service gets the quality that I expect, I hope I have found a very good and cheap resource.

Ja en sumo 39; no ús perdeu qui m’ha felicitat aquest any

Reading time: 1 – 2 minutes

Un any més sumo una unitat a la compte i ja en van 39. Els 40 s’acosten però la veritat és que no li dono més importància del que té. La vida passa i les experiències s’acumulen. Per sort hi ha coses que realment hem fan somriure, algunes les podeu veure aquí:

pastis

d’altres aquí:

 

i fins hi tot podeu escoltar grans felicitacions com aquest del mateix Fidel Castro XDDD

 

 

Moltíssimes gràcies a tots els que us heu recordat de mi i als que no també, una fortíssima abraçada amb molt d’amor. GRÀCIES!

 

Sniffing traffic in a Linux box and streaming in real-time to Wireshark on Windows

Reading time: 4 – 6 minutes

Sniffing and inspect complex protocols on “tcpdump” is usually painful. Of course, “tcpflow” is a very useful tool but is not always enough to sniff in a console. Wireshark is always a better option when it’s time to debug and troubleshooting communication problems.

But it’s not always easy to plug a Network TAP where you want to sniff. If at that point we have a Linux box with “ssh” and “tcpdump”. An interesting option is stream sniffed traffic to another box with Wireshark and dissect packet octets in their layers, fields, etc.

When Wireshark box is based on Windows you need “plink.exe“, and you can do thinks like that:

plink.exe -ssh -pw LINUX_BOX_PASSWORD root@LINUX_BOX_IP "tcpdump -n -i INTERFACE_TO_SNIFF -s 0 -w - not port 22" | "%PATH_TO_WIRESHARK\Wireshark.exe" -k -i -

Next you have a screenshot with a real life example of that:

tcpdump_streams_to_wireshark_secure

MacBook Air battery explossion

Reading time: 2 – 2 minutes

Two months ago I went to get my “Mac Book Air mid2011 version” and found that:

The batteries had exploded! It is curious bacause I have laptops saved for many years, one would say it has almost 20 years. Obviously the battery lasts very little but has never exploited. It is incredible that a brand that cares the quality of its product as Apple and a product that was the best in its class 5 years ago; today without more than being on a shelf it has exploded from one day to the other.

In Apple store didn’t want to know about the problem because it is out of guarantee; luckly it wasn’t my daily laptop and after buying a new battery in ebay I have changed the battery for les than 50€ and the laptop keeps running.

bateria-apple

I don’t know if anybody else suffered that experience but IMHO Apple has failed and I’m very disappointed with their reaction with my issue with the product. I know it’s not on guarantee but I paid close to 1.700€ on a Laptop less than 5 years ago and I don’t expect that. Clearly this is a manufacturing problem with the battery. I have to recognize once again that Apple has very good quality products, or not, but day after day their customer support is being worst.

Just a final note my actual laptop is a Toshiba, I’m not proud of it but it works quite good so far today is for far more powerful than current MacBook Air with the same weight amd I don’t have to carry a lot of connectors and cables because everything is embedded, included the 4G modem.

Yo quiero ser así

Reading time: 9 – 15 minutes

Últimamente los domingos a estas horas intento encontrar unos minutos para hacer mi resumen semanal. Para ello tengo una rutina muy bien definida que a continuación me gustaría describir. Pero antes de entrar al contenido quería compartir el porqué empecé a hacer esto. La respuesta es muy sencilla, por la vida encontramos a muchas personas; todas aparecen porqué nos tienen que enseñar alguna cosa pero hay algunas que además de hacer esto provocan cambios importantes, cambios de raíz. Te pueden cambiar hasta en quien quieres ser, cosa que diría que es todavía más importante. Si quereis profundizar un poquito más en el tema una muy buena forma de hacerlo es ver este video de TEDxAndorra, concretamente de Victor Küppers una de esas personas que sin tener la suerte de conocerlas ya te inspiran.

Los que me conoceis sabeis que desde los 9 años mi vida se mueve alrededor de una pasión. La tecnología me cautiva y no puedo evitar invertir infinidad de horas y energía disfrutándola de mil formas. Pues bien, como todas las pasiones incontroladas creo que lo que acaban haciendo es convertirnos en personas descompensadas personas que acaban perdiendo el referente de lo que realmente es importante y focalizan toda la existencia hacia esa actividad.

Por suerte ya hace muchos años varias de esas personas que te cambian se cruzaron en mi camino. Después de abrir los ojos he dejado que esa energía y vitalidad que siento hacia mi pasión permita iluminar el resto de areas de mi vida. Ese amor y pasión me dan una fuerza y una ilusión que me motivan a hacer lo que algunos califican de locuras, los otros lo etiquetan como ser perseverante o metódico. Yo la verdad no me atrevo a ponerle un nombre, simplemente me funciona.

Lo que si sé, es que cada mañana a las 5:50 mis ojos se abren como dos faros, una sonrisa se dibuja en mis labios; de un salto me levanto de la cama y después de la visita obligada al WC invierto mis primera horas del día en sumergirme en unos minutos de meditación. El siguiente paso es el que os quiero compartir y se trata de preguntarme cuatro cositas, se trata de proyectarme sobre mi día y de vivir antes de que pase la realidad que quiero vivir hoy.

Hoy quiero compartir con esta entrada en mi blog las preguntas que respondo por escrito cada mañana y las que respondo cada noche. Además al llegar el domingo a estas horas aprovecho para re-leer esas respuestas y responder mis preguntas semanales. Finalmente cada mes y cada año vuelvo a trabajar sobre este material. Seguramente os preguntareis y porqué todo esto? pues porqué no me conformo en que sólo mi inconsciente dirija mi camino, no es suficiente para mi ser como mi voz interior dice que me debo comportar.

Con este trabajo lo que he hecho con los años es ir creándome como de verdad quiero ser, como se que lo consigo? muy sencillo, sólo me hace falta abrir bien los ojos y las orejas, al ver y escuchar lo que pasa a mi alrededor cada día me dice si lo hago bien o mal. Si mi día a día es realmente un sueño tan bonito del que no quiero despertar jamás, o si se parece a una pesadilla de la que quiero escapar. Si os preguntáis en que punto estoy, sólo os diré lo que me gusta contestar cuando alguien me ofrece café: “No, gracias. No me gustaría despertar de este fantástico sueño que es mi vida. Mejor me tomo una tila y me permito contemplar lo fantástico que es el mundo y dejar de correr sin saber porqué.

Volviendo a las preguntas, lo primero es escribir una lista de cosas por las que estoy agradecido. Me tomo mi tiempo y me permito respirar muy pausadamente y profundamente para sentir desde mi interior que salgan esas cosas por las que me siento agradecido. No importa lo que sea, no importa si es material, inmaterial, una persona, animal o planta. Simplemente me permito sentir como la gratitud sale de mi.

A continuación repito un mantra. Se trata de aceptarme, de perdonarme y finalmente de quererme. Me costó muchos años entender que sólo podía querer a los demás si me quería con plenitud a mi mismo. No me fue fácil, hay tantas y tantas cosas que me cuesta aceptar de mi que ni siquiera me permito perdonarme; durante este ejercicio me gusta sentir esas emociones recorrer mi interior y cuando concluyo la repetición del mantra con los ojos cerrados, una sonrisa en mis labios y repitiendo en voz alta que me quiero noto un subidón de energía brutal.

Cada mañana me gusta re-escribir cual es mi objetivo trascendental y me gusta tenerlo presente por eso asumo que ese objetivo esta dentro de mi y que debo permitirme sentirlo una y otra vez para que se pueda materializar. El enunciado que tengo en mi lista de tareas diarias es este: “Actuar como si ya tubiera lo que deseo, dar las gracias por tener lo que deseo“.

En este momento estoy listo para empezar a responder las primeras preguntas del día. La primera es “Dar las gracias a una persona por algo“. Se trata de buscar en el mundo alguien concreto al que darle las gracias por algo en concreto. Esta pregunta acostumbra a serme muy fácil de contestar, las siguientes son: “¿Qué hay de hermoso en este día?” y “¿Qué quiero aprender hoy?“. Sigo con. “¿Cómo puedo mejorar hoy?” y proyecto seguidamente la respuesta de la pregunta sobre la siguiente cuestión “¿En qué modo esto que aprenderé hoy, influirá y será importante para mi vida?“.

La última pregunta es en forma de petición; “¿Que le pido hoy a mi subconsciente?“. Recordándome que mi metáfora personal es el agua y que una de las propiedades fantásticas que esta tiene es fluir a través del camino empiezo a visualizar en mi mente lo que haré el resto del día, aprovecho cuando aparecen bloques de tiempo libres para anotarlos y cuando mentalmente he llegado al final del día voy llenando esos bloques de tiempo repasando mis listas de tareas (TODO lists); no me perderé con los criterios que uso para filtrar las tareas pero hay todo un trabajo detrás para hacer la selección (GTD). Eso si, si queréis recordar o saber porqué mi metáfora es el agua recomiendo esta entrada: Ser aigua.

Llegados a este punto alguien podría pensar que mi día esta plenamente planeado a primera hora, pero la realidad no tiene nada que ver. Ese es mi objetivo y por el que voy a trabajar durante el día; tengo claras las tareas clave que si o si voy a hacer y las que podría ser que no fuera posible ejecutar. Pero lo fundamental es permitirme fluir a través del día, permitirme sentirme pleno e infinitamente feliz de vivir el que sólo puede ser el mejor día de mi vida; simplemente porqué sólo existe hoy y así es como quiero vivirlo.

Antes de acabar el día, o en su defecto, a la mañana siguiente hay las preguntas que complementan a las de la mañana. Empiezo describiendo muy brevemente el día, una palalbra, una frase o un largo párrafo; todo es más que suficiente. Sigo preguntándome “¿qué cosas he aprendido hoy?” es curioso observar al final de la semana, cuando repaso el trabajo hecho, como esta pregunta siempre esconde interesantes sorpresas. Después escribo la respuesta de “¿Qué hice hoy para superarme y mejorar?” y seguidamente saltar a “¿qué me ha dejado el día de hoy?“. Las emociones del día las repaso con esta pregunta “¿qué emociones experimenté?” que a menudo tiene una fuerte relación con la siguiente multi-pregunta “¿con quién lo he compartido?¿a quien amé?¿quien me amó hoy?“.

Para acabar dedico un par de minutos a resumir en inglés y en pasado lo que ha pasado en el día, se trata de ser totalmente subjetivo y no intentar racionalizar nada de lo que me viene a la mente. Lo hago en inglés para practicar si durante el día no he tenido reuniones en inglés y me fuerzo a hablar en pasado porqué a menudo cuando hablo en inglés lo hago en presente y futuro cosa que no me permite practicar los tiempos verbales en pasado. Así que aquí trabajo en dos temas a la vez, en captar mi estado de ánimo y en mi inglés.

Para concluir tengo otro karma que me gusta repetirme y sobre el que me gusta inspirarme. Se trata de una metáfora que me recuerda que debo soltar las cosas para poder descansar en paz, concretamente es este “Baja el vaso, así tu brazo podrá descansar“.

El cierre de la semana se compone de las siguientes preguntas:

  • ¿Qué he aprendido durante la última semana?
  • ¿Cuál fue mi mayor logro de la semana pasada?
  • ¿Qué momento de la semana pasada fue el más memorable y por qué? Identificar pasiones y objetivos.
  • ¿Cuál es la tarea más importante para llevar a cabo la semana que viene?
  • ¿Qué puedo hacer ahora para facilitar el trabajo de esta semana? Llenar el depósito, programar alarmas en el calendario para reuniones importantes, etc.
  • ¿Qué problemas del pasado pueden volver a manifestarse durante la semana que viene? Aprende del pasado para estar preparado para el futuro.
  • ¿En qué tarea he perdido más tiempo en la última semana? Busca una estrategia para evitar que vuelve a pasar.
  • ¿Qué tarea he estado evitando? Planifica esta tarea en tu agenda, si es posible el lunes a la primera hora de la mañana.
  • ¿A quién puedo ayudar la semana que viene? La mejor manera de recibir ayuda es ayudar a los demás para que se acuerdan de ti cuando necesites ayuda.
  • ¿Cuáles son mis tres objetivos para los próximos dos años? Si tengo mis objetivos presentes, tendré más posibilidades de avanzar durante la semana que viene.* ¿Alguna de mis acciones de la semana pasada me han acercado a mis objetivos? Si la respuesta es negativa, algo hay que cambiar durante la semana que viene.

Ahora mismo sería incapaz de decir de donde he sacado todas estas preguntas. Lo que si sé es que no fue un trabajo que empezó y que sigue igual, con el tiempo voy quitando y añadiendo preguntas. Algunas las leo en blogs, otras en libros, las oigo en conferencias o simplemente se me ocurren. Así que GRACIAS a todos lo que me habeis inspirado. Lo que para mi es importante es buscar esa serie de actividades que me permitan construirme como quiero ser, que me permitan crearme como el señor Küppers nos dice en el video. Evidentemente la genética tiene su fuerza y nos condiciona, pero por mi propia experiencia os puedo asegurar que cuando hay ilusión no hay genética que te frene las ganas.

Termino, como siempre, deseando que el hecho de compartir este pedacito de mi intimidad le sirva a alguien para poder empezar a crearse como realmente quiere ser. No somos otra cosa que personas y las actividades o comportamientos que llevamos a cabo es como nos manifestamos, sólo cambiando la forma de mirar a la vida todo ello puede cambiar; yo lo he hecho, por eso creo que todo el mundo puede.

Copia local del video:

Scroll to Top