Saturday, October 23, 2021

Linux SWAP Operation

 # swapoff /dev/mapper/swap

swapoff: /dev/mapper/swap: swapoff failed: Cannot allocate memory


# dd if=/dev/zero of=/home/swap bs=1024 count=1024000


# swapon /home/swap


swapon: /home/swap: insecure permissions 0644, 0600 suggested.

  swapon: /home/swap: read swap header failed: Invalid argument


# mkswap /home/swap 

# swapon /home/swap


# free

              total        used        free      shared  buff/cache   available

Mem:       32782064    30765328      262560     1607488     1754176      219732

Swap:       1654776      401236     1253540

# swapon -s

Filename                                Type            Size    Used    Priority

/dev/mapper/swap                               partition       630780  0       -2

/home/swap                              file    1023996 401236  -1

# swapoff /home/swap

# swapon -s

Filename                                Type            Size    Used    Priority

/dev/mapper/swap                               partition       630780  431836  -1

# rm /home/swap 

rm: remove regular file ‘/home/swap’? y

# free -h

              total        used        free      shared  buff/cache   available

Mem:            31G         29G        222M        1.6G        1.7G        190M

Swap:          615M        421M        194M


Friday, June 4, 2021

SSH Key Manipulation


Key Format:

RSA Public Key

-----BEGIN RSA PUBLIC KEY-----
-----END RSA PUBLIC KEY-----

Encrypted Private Key

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
-----END RSA PRIVATE KEY-----

CRL

-----BEGIN X509 CRL-----
-----END X509 CRL-----

CRT

-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----

CSR

-----BEGIN CERTIFICATE REQUEST-----
-----END CERTIFICATE REQUEST-----

NEW CSR

-----BEGIN NEW CERTIFICATE REQUEST-----
-----END NEW CERTIFICATE REQUEST-----

PEM

-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----

PKCS7

-----BEGIN PKCS7-----
-----END PKCS7-----

PRIVATE KEY

-----BEGIN PRIVATE KEY-----
-----END PRIVATE KEY-----

DSA KEY

-----BEGIN DSA PRIVATE KEY-----
-----END DSA PRIVATE KEY-----

Elliptic Curve

-----BEGIN EC PRIVATE KEY-----
-----END EC PRIVATE KEY-----

PGP Private Key

-----BEGIN PGP PRIVATE KEY BLOCK-----
-----END PGP PRIVATE KEY BLOCK-----

PGP Public Key

-----BEGIN PGP PUBLIC KEY BLOCK----- 

-----END PGP PUBLIC KEY BLOCK-----Check Key 


openssl asn1parse -i -in a.pem

Convert PKCS8 key to ssh-rsa format

 ssh-keygen -f a.pub -i -m PKCS8

Sunday, May 9, 2021

Creating a private API in Amazon API Gateway

apigateway-resource-policies-examples

https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-private-apis.html

https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-resource-policies-examples.html

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpcendpoint.html#cfn-ec2-vpcendpoint-vpcendpointtype

Launch Cloudformation template with Terraform

https://stackoverflow.com/questions/43266506/is-it-possible-to-execute-a-cloudformation-file-in-terraform