martes, 8 de enero de 2019

GPG

Create a key pair.

gpg --gen-key

 List keys.

 gpg --list-keys

Export a public key

 gpg --export UID file.pub

Import a public key 

gpg --import file.pub

Create an encrypted and signed file. 

gpg -se -u "Sender User Name" -r "Receiver User Name" somefile

Decrypt a file. 

gpg -d mydata.tar.gpg

Typical key management with OpenSSL

Generate private key:
openssl genrsa -aes128 -passout pass:foobar -out privkey.pem 2048
Extract public key from private key:
openssl rsa -pubout -in privkey.pem -out pubkey.pem
Display data from the key file:
openssl rsa -text -in private_key.pem
Remove the key proteccion.
openssl rsa -in [file1.key] -out [file2.key]

LVM How to

create the partitions:

fdisk /dev/sdb

Partition type:
8e

pvcreate /dev/sdb1
pvcreate /dev/sdb2

vgcreate vgtest /dev/sdb1 /dev/sdb2
vgscan

lvcreate -L 1G vgedir


pvcreate /dev/sdb3
vgextend vgtest /dev/sdb3
vgscan

lvextends -L 500M vgedir

linux-f0cx:/ # resize2fs /dev/vgedir/tlv +500M
resize2fs 1.41.9 (22-Aug-2009)
Please run 'e2fsck -f /dev/vgedir/tlv' first.

linux-f0cx:/ # e2fsck -f /dev/vgedir/tlv
e2fsck 1.41.9 (22-Aug-2009)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vgedir/tlv: 34/65536 files (0.0% non-contiguous), 12667/262144 blocks

linux-f0cx:/ # resize2fs /dev/vgedir/tlv +1500M
resize2fs 1.41.9 (22-Aug-2009)
Resizing the filesystem on /dev/vgedir/tlv to 128000 (4k) blocks.
The filesystem on /dev/vgedir/tlv is now 128000 blocks long.



  230  pvcreate /dev/sdb1
  231  pvcreate /dev/sdb2
  232  pvcreate /dev/sdb3
  233  pvcreate /dev/sdb
  234  pvcreate /dev/sdb4
  235  vgcreate vg0 /dev/sdb1 /dev/sdb2
  236  vgdisplay
  237  lvcreate 
  238  lvcreate --help
  239  lvcreate -L 1G var
  240  lvcreate -L 1G /dev/vg0/var
  241  lvcreate -L 1G vg0 var
  242  lvcreate -L 1G vg0 -n var
  243  lvdisplay
  244  mkfs.ext3 /dev/vg0/var
  245  e2fsck /dev/vg0/var 
  246  history