Y otra de utilidad

March 24th, 2021

Hola, despues de mucho pero muhco de no escribir y recuperar el dominio aqui estamos,

Tenia una vm con linux y tenia que encriptar el disco crypto_LUKS, y pues asi la tenia, resulta que pues valio queso y no podia entrar ni podia montar el disco, bucando informacion pude recuperar mi info, aqui se los dejo por si alguien neceista hacer algo similar

instalar los siguiente paqetes:

dnf install cryptsetup-reencrypt.x86_64 pam-cryptsetup.x86_64
cryptsetup luksOpen /dev/sdb3 new_sdb3
mount /dev/mapper/new_sdb3 /mnt

En mi caso era la particion sdb3, con eso pude montarla y sacar la informacion que necesitaba recuperar, mi una bronca fue que mi vm si quedo ya pa la basura.

Instalar AWS Cli

January 28th, 2019

Pues eso del AWS Cli esta muy sencillo, pero de repente tengo que volver a instalarlo, aqui lo pasos para hacer la instalacion.

la info del sistema que estoy utilizando en este momento es y uso pip para la instalacion.

 
$ uname -a
Linux lapaepamX 4.19.14-300.fc29.x86_64 #1 SMP Wed Jan 9 21:30:35 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
 
$ pip install awscli --upgrade --user
Collecting awscli
  Downloading https://files.pythonhosted.org/packages/25/f2/ae339ba36dc8774b8fb2b7da1b7351ccdedc7af4b2458221e7ac865b4d2d/awscli-1.16.96-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 4.6MB/s 
Collecting s3transfer<0.2.0,>=0.1.12 (from awscli)
  Downloading https://files.pythonhosted.org/packages/d7/14/2a0004d487464d120c9fb85313a75cd3d71a7506955be458eebfe19a6b1d/s3transfer-0.1.13-py2.py3-none-any.whl (59kB)
    100% |████████████████████████████████| 61kB 67kB/s 
Collecting colorama<=0.3.9,>=0.2.5 (from awscli)
  Downloading https://files.pythonhosted.org/packages/db/c8/7dcf9dbcb22429512708fe3a547f8b6101c0d02137acbd892505aee57adf/colorama-0.3.9-py2.py3-none-any.whl
Collecting rsa<=3.5.0,>=3.1.2 (from awscli)
  Downloading https://files.pythonhosted.org/packages/e1/ae/baedc9cb175552e95f3395c43055a6a5e125ae4d48a1d7a924baca83e92e/rsa-3.4.2-py2.py3-none-any.whl (46kB)
    100% |████████████████████████████████| 51kB 345kB/s 
Collecting docutils>=0.10 (from awscli)
  Downloading https://files.pythonhosted.org/packages/50/09/c53398e0005b11f7ffb27b7aa720c617aba53be4fb4f4f3f06b9b5c60f28/docutils-0.14-py2-none-any.whl (543kB)
    100% |████████████████████████████████| 552kB 668kB/s 
Collecting PyYAML<=3.13,>=3.10 (from awscli)
  Downloading https://files.pythonhosted.org/packages/9e/a3/1d13970c3f36777c583f136c136f804d70f500168edc1edea6daa7200769/PyYAML-3.13.tar.gz (270kB)
    100% |████████████████████████████████| 276kB 747kB/s 
Collecting botocore==1.12.86 (from awscli)
  Downloading https://files.pythonhosted.org/packages/d7/af/fd9c0f1f0fdc03d3367a56f35093f8b1020ba1a97ead9fa580156895944b/botocore-1.12.86-py2.py3-none-any.whl (5.2MB)
    100% |████████████████████████████████| 5.3MB 1.0MB/s 
Collecting futures<4.0.0,>=2.2.0; python_version == "2.6" or python_version == "2.7" (from s3transfer<0.2.0,>=0.1.12->awscli)
  Downloading https://files.pythonhosted.org/packages/2d/99/b2c4e9d5a30f6471e410a146232b4118e697fa3ffc06d6a65efde84debd0/futures-3.2.0-py2-none-any.whl
Collecting pyasn1>=0.1.3 (from rsa<=3.5.0,>=3.1.2->awscli)
  Downloading https://files.pythonhosted.org/packages/7b/7c/c9386b82a25115cccf1903441bba3cbadcfae7b678a20167347fa8ded34c/pyasn1-0.4.5-py2.py3-none-any.whl (73kB)
    100% |████████████████████████████████| 81kB 1.2MB/s 
Collecting jmespath<1.0.0,>=0.7.1 (from botocore==1.12.86->awscli)
  Downloading https://files.pythonhosted.org/packages/b7/31/05c8d001f7f87f0f07289a5fc0fc3832e9a57f2dbd4d3b0fee70e0d51365/jmespath-0.9.3-py2.py3-none-any.whl
Collecting python-dateutil<3.0.0,>=2.1; python_version >= "2.7" (from botocore==1.12.86->awscli)
  Downloading https://files.pythonhosted.org/packages/74/68/d87d9b36af36f44254a8d512cbfc48369103a3b9e474be9bdfe536abfc45/python_dateutil-2.7.5-py2.py3-none-any.whl (225kB)
    100% |████████████████████████████████| 235kB 1.1MB/s 
Collecting urllib3<1.25,>=1.20; python_version == "2.7" (from botocore==1.12.86->awscli)
  Downloading https://files.pythonhosted.org/packages/62/00/ee1d7de624db8ba7090d1226aebefab96a2c71cd5cfa7629d6ad3f61b79e/urllib3-1.24.1-py2.py3-none-any.whl (118kB)
    100% |████████████████████████████████| 122kB 1.2MB/s 
Collecting six>=1.5 (from python-dateutil<3.0.0,>=2.1; python_version >= "2.7"->botocore==1.12.86->awscli)
  Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Installing collected packages: futures, jmespath, docutils, six, python-dateutil, urllib3, botocore, s3transfer, colorama, pyasn1, rsa, PyYAML, awscli
  Running setup.py install for PyYAML ... done
Successfully installed PyYAML-3.13 awscli-1.16.96 botocore-1.12.86 colorama-0.3.9 docutils-0.14 futures-3.2.0 jmespath-0.9.3 pyasn1-0.4.5 python-dateutil-2.7.5 rsa-3.4.2 s3transfer-0.1.13 six-1.12.0 urllib3-1.24.1

crear particion con parted

March 7th, 2018

Por lo general siempre que he creado particiones las he creado con fdisk, pero bueno el fdisk ya no nos permite crear particiones tan grandes, otra por que en la chamba ya no quieren que usemos fdisk si no parted 😛 y a parte con formato gpt, ya no msdos para soporte de mbr 😛 bueno asi que veamos como crear una particion sencilla con parted

 
 

~]# parted -a optimal /dev/xvdc
GNU Parted 2.1
Using /dev/xvdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help                                                             
  align-check TYPE N                        check partition N for TYPE(min|opt) alignment
  check NUMBER                             do a simple check on the file system
  cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER   copy file system to another partition
  help [COMMAND]                           print general help, or help on COMMAND
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
  mkfs NUMBER FS-TYPE                      make a FS-TYPE file system on partition NUMBER
  mkpart PART-TYPE [FS-TYPE] START END     make a partition
  mkpartfs PART-TYPE FS-TYPE START END     make a partition with a file system
  move NUMBER START END                    move partition NUMBER
  name NUMBER NAME                         name partition NUMBER as NAME
  print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or a particular
        partition
  quit                                     exit program
  rescue START END                         rescue a lost partition near START and END
  resize NUMBER START END                  resize partition NUMBER and its file system
  rm NUMBER                                delete partition NUMBER
  select DEVICE                            choose the device to edit
  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
  unit UNIT                                set the default unit to UNIT
  version                                  display the version number and copyright information of GNU Parted
(parted) mklabel gpt                                                      
(parted) print                                                            
Model: Xen Virtual Block Device (xvd)
Disk /dev/xvdc: 215GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
 
Number  Start  End  Size  File system  Name  Flags
 
(parted) print free                                                       
Model: Xen Virtual Block Device (xvd)
Disk /dev/xvdc: 215GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
 
Number  Start   End    Size   File system  Name  Flags
        17.4kB  215GB  215GB  Free Space
 
(parted) help unit
  unit UNIT                                set the default unit to UNIT
 
	UNIT is one of: s, B, kB, MB, GB, TB, compact, cyl, chs, %, kiB, MiB, GiB, TiB
(parted) unit GiB                                                         
(parted) print free
Model: Xen Virtual Block Device (xvd)
Disk /dev/xvdc: 200GiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
 
Number  Start    End     Size    File system  Name  Flags
        0.00GiB  200GiB  200GiB  Free Space
 
 
(parted) mkpart primary 0 200                                             
(parted) name 1 u01                                                       
(parted) print                                                            
Model: Xen Virtual Block Device (xvd)
Disk /dev/xvdc: 200GiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
 
Number  Start    End     Size    File system  Name  Flags
 1      0.00GiB  200GiB  200GiB               u01
 
(parted) quit                                                             
Information: You may need to update /etc/fstab.      
 
 
     ~]# mkfs.ext4 /dev/xvdc1
mke2fs 1.43-WIP (20-Jun-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
13107200 inodes, 52428288 blocks
2621414 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
1600 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872
 
Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done  
 
~]# vi /etc/fstab
 
Montamos la particion  y si le damos un df en este caso ya etara vible nuestra particion de /dev/xvdc1

Conectarse remotamente usando llaves publicas y privadas

March 3rd, 2018

 

ssh


 

ssh un protocolo de comunicación que encontramos en la capa de aplicación del protocolo de comunicación TCP/IP, ssh nos sirve para establecer conexiones de manera remota y de manera segura entre servidores.

Por lo general cuando usamos ssh siempre a la hora de hacer la conexión del lado del servidor nos preguntara un usuario y un passwd. Así mismo cuando tenemos muchos servidores pues es algo engorroso tener un montón de passwds. en otras ocaciones las políticas de passwd son algo complejas de equis número de caracteres, números, caracteres especiales, mayusculas y minúsculas.

 

Una imagen para medio explicar como funciona el protocolo de comunicación de SSH

 
 

ssh

No se ustedes pero en lo personal no me aprenderia tantisimas contraseñas.

entonces lo que podemos hacer es generar nuestra llave y subirla a los servidores a donde necesitamos ingresar y ya sea que usemos una llave con alguna frase mas sencilla o dejarla sin frase.

Hacemos lo siguiente si mi usuarios es xanatos y quiero ingresar a mi maquina vmclase001 sin tener que usar passwd haremos lo siguiente.

 

ssh-keygen -t rsa -b 4096 -C "bernardo.mejia@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/xanatos/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/xanatos/.ssh/id_rsa.
Your public key has been saved in /home/xanatos/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Choz61K1xeFpqf6o66AT1LX8I/7I6KXMWnThT4bSV9g bernardo.mejia@gmail.com
The key's randomart image is:
+---[RSA 4096]----+
|                 |
|     .. o        |
|  . o+.= E       |
| . .+oX .        |
|. ++.X.+S        |
|. o*=o=+         |
|.ooo..o..        |
|+o+ *o.          |
|.=BO.+o.         |
+----[SHA256]-----+

como podemos ver ejecutamos el ssh-keygen se genera nuestra llave publica y privada dentro de nuestro home directory y en el subdirectorio .ssh y genera mis archivo id_rsa e id_rsa.pub.

Copiamos nuestra llave pulica al server al archivo authorized_keys

en el server si no existe el archivo lo creamos

touch authorized_keys
vi authorized_keys
 
$ cat authorized_keys 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCqF4X5322/2MbloaZAIKXLvfqz7ZxSJYmdYlXluNZqZvPZ7W4qF78/kL7n+N2EUrGR1oPkd0kJaAZuQvJyPiYO2L+GaraS5IRJoWbqbM1yAP0htAhsuSx1Gj+DBe2H8IcANGQ9aG9nmlouykAWcut2bEPdvglOI2hjPi71OJvJbh10AXL4leaBuJbFOkxSqwoH15RAo6kPgcZhhyNkhKcS0qv0FPQ9F46LLuQuAcBfZCOzTYjlfMt418GQaL61LjGIK48l3Tl7Yo1RwJMRZrwWJUvmNsDXmovmkhfcbVVJGXsVR21X22AVq+8l1F9yXUUAKNeqT3BLTrThlGZc0PiLANaqYm60m/okDdy+UT8NCYxy6TCggQxpIsOuQaPfQfWEzNDBf7+dTL9VudECcHyPAHdXEOMnBvRXI/Vk9IKng3j7fILtDsfkkSp8Hd1z50ascpmam7fgInghz1RY/YmhPPqsIUiWkvHM24+o08pbiyrL6BjGldcuBAyRsFzuB573+vldp9i9LQxPjK5FuIUN2bc12w6TatS/VUkMDPyjcFPzENvccdB9aQ3odSw1QLPcIqyGw5S/azE6Ay4kwak6hblBzT1ztIKiI9v873f0CjOmOjYzT4DkBZOmbc7sld5XMmeNdFOP/kbcDj+ggCyEOBx7tPixD81Qia6AWm7FjQ== bernardo.mejia@gmail.com
xanatos@vmclase001:~/.ssh$

Ahora ya subimos nuestra llave y en teoría ya podemos entrar al server sin necesitad de una centraseña!

intentamos

~$ ssh xanatos@mysqlvm001.bmejiaparedes.mx
The authenticity of host 'mysqlvm001.bmejiaparedes.mx (62.151.176.96)' can't be established.
ECDSA key fingerprint is SHA256:igQgIOtrN74YqwH+uCQONWfTwyCItXgXspFUBaVY8PI.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'mysqlvm001.bmejiaparedes.mx,62.151.176.96' (ECDSA) to the list of known hosts.
xanatos@mysqlvm001.bmejiaparedes.mx's password:

Nos damos cuenta que nos sigue pidiendo passwd, necesitaremos revisar los permisos y tenemos que tener los archivos con los siguientes permisos

 

~/.ssh$ ls -ltr
total 16
-rw-r--r-- 1 xanatos xanatos  750 mar  3 11:14 id_rsa.pub
-rw------- 1 xanatos xanatos 3243 mar  3 11:14 id_rsa
-rw------- 1 xanatos xanatos  750 mar  3 11:21 authorized_keys
-rw-r--r-- 1 xanatos xanatos  444 mar  3 11:25 known_hosts

 

Volvemos a intentar y ahora si podemos entrar sin necesidad de poner una contraseña y solo co nuestra llave.

:~/.ssh$ cd
xanatos@vmclase001:~$ 
xanatos@vmclase001:~$ ssh xanatos@mysqlvm001.bmejiaparedes.mx
Last login: Sat Mar  3 17:32:13 2018 from fixed-189-203-149-57.totalplay.net
[xanatos@vmX ~]$

 

Ahora si ya existe el usuario y tenemos el acceso a las llaves usaremos nuestra llave privada para poder acceder al usuario

aquí tenemos las llaves del usuario clasex1 y haremos lo siguiente

xanatos@vmclase001:~$ ls -ltr |grep id
drwxr-xr-x 2 xanatos xanatos 4096 feb 21 21:28 Videos
-rw------- 1 xanatos xanatos 3243 mar  3 08:34 id_rsa_clasex1
-rw------- 1 xanatos xanatos  744 mar  3 08:34 id_rsa_clasex1.pub
xanatos@vmclase001:~$ 
 
xanatos@vmclase001:~$ ssh -i id_rsa_clasex1 clasex1@mysqlvm001.bmejiaparedes.mx
Last login: Sat Mar  3 16:44:09 2018 from fixed-189-203-149-57.totalplay.net
[clasex1@vmX ~]$

 

Ahora solo usamos nuestra llave privada que fue con anterioridad compartida para con nosotros. :p

Vieve!

July 24th, 2017

Pues sigue vivo!!!!

FSL se acerca

October 5th, 2014

Dropbox con proxy

September 1st, 2014

Bien tal vez para muchos es muy sencillo, en realidad si lo es, pero bueno si alguien esta usando una red donde se tiene un proxy para poder salir a la Internet pues le puede servir esto.

Para setear el proxy es muy sencillo, esolo se le tiene que dar boton derecho –> Preferencias y dar click en el ab de Proxies y magia, solo lo setean.

en caso de que este usando la linea de comandos, es mas que suficiente solo exportar la variable:

 

http_proxy
https_proxy

 

Y listo, iniciar el servicio del dropbox

$ dropbox start

Esto iniciara el servicio del dropbox y de pronto veran que se comienzan a sincronizar todos nuestros archivos y carpetas de nuestro dropbox.

Revisar que un puerto este disponible con nc

August 20th, 2014

Muy simple si quiero revisar que un puerto este abierto con nc solo hacer lo siguiente:

 

nc -z -w3 <host> <port>; 
Connection to <host> <port> port [tcp/ldaps] succeeded!

Otra de utilidad con VirtualBox

August 15th, 2014

Algo que de repente necesito es iniciar una vm de virtualbox en linea de comandos, bueno es muy sencillos aqui se los dejo.

  VBoxManage startvm debian --type headless

Así de sencillo es arrancar la vm

Remover virbr0

February 24th, 2014

Bueno a la hora de instalar por default la parte de virtualizacon en centos y al arrancar la maquina, a la hora de dar un ifconfig vemos una mentada interfaz “virbr0” es nuestro puente para poder tenet comunicacion con nuestras futuras maquinas virtuales, pero si queremos hacer los bridge de manera manual y a nuestro gusto pues luego usaremos el brctl para eso. Mientras queremos remover la interfaz que nos crea.

corremos los siguientes comandos

# ifconfig virbr0
 
virbr0    Link encap:Ethernet  HWaddr 52:54:00:B7:91:19  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
 
 
 
# virsh net-list
Name                 State      Autostart     Persistent
--------------------------------------------------
default              active     yes           yes
 
 
]# virsh net-destroy default
Network default destroyed
 
# virsh net-undefine default
Network default has been undefined
 
# service libvirtd restart
Stopping libvirtd daemon:                                  [  OK  ]
Starting libvirtd daemon: 2014-02-24 16:46:54.975+0000: 2318: info : libvirt version: 0.10.2, package: 29.el6 (CentOS BuildSystem <http://bugs.centos.org>, 2013-11-23-13:07:07, c6b8.bsys.dev.centos.org)
2014-02-24 16:46:54.975+0000: 2318: warning : virGetHostname:2294 : getaddrinfo failed for 'vcloud': Name or service not known
                                                           [  OK  ]
 
# virsh net-list
Name                 State      Autostart     Persistent
--------------------------------------------------
 
 
# ifconfig virbr0
virbr0: error fetching interface information: Device not found

Listo ya no esta presente.