Friday, October 29, 2021

Terraform and OCI Compute Instance Provisioning.

Problem:

Error: 404-NotAuthorizedOrNotFound 

Provider version: 4.43.0, released on 2021-09-08. This provider is 7 update(s) behind to current. 

Service: Core Instance 

Error Message: Authorization failed or requested resource not found. 

OPC request ID: 4d08355655dc4bcd2f6ebc9b13fc582e/EE6FD3C4D7841A48A633023A67285401/B89D25D770B24C7D17E47E1F5EC2D9AC 

Suggestion: Either the resource has been deleted or service Core Instance need policy to access this resource. Policy reference: https://docs.oracle.com/en-us/iaas/Content/Identity/Reference/policyreference.htm

Cause:

The source resource and the destination resource are in different regions. for example, You planned to create compute instance in ap-sydney-1 region, but the source image is in ap-tokyo-1.

Solution:

Use the source image in the same region as the compute instance.

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