Extremely Serious

Category: Tool (Page 2 of 4)

Using Rsync to Sync a Local Directory to Another Local Directory

Syntax

To sync some of your local directories to another local directory, you can use the following syntax:

rsync -av -L --delete <DIR1>[[ <DIR2>] <DIRn>] <DESTINATION_DIR>
Token Description
DIR1, DIR2, DIRn These are the local directories you've wanted to be synced. Only DIR1 is required and the rest are optional.
DESTINATION_DIR The destination directory on the remote machine.

Example

rsync -av -L --delete /var/log/ /data/log/

Using Detach ASCII Signature to Verify a File

Import Keys from Keyserver

Run the following command:

gpg --receive-keys <KEY_ID>

Showing the Fingerprints

Run the following command:

gpg --fingerprint <KEY_ID>

Verifying a File with ASCII Key

  1. Download the detach asc <ASC_FILE> file associated to the file.
  2. Download the signed file <SIGNED_FILE> file.
  3. Use the following command for verification:
    gpg --verify <ASC_FILE> <SIGNED_FILE>

Generating PGP Keys with Gpg4win

Pre-requisite

Generating Keys

    1. Run the following command:
      gpg --full-gen-key
    2. Type 1 and press enter for the following question:
      Please select what kind of key you want:
         (1) RSA and RSA (default)
         (2) DSA and Elgamal
         (3) DSA (sign only)
         (4) RSA (sign only)
      Your selection?
    3. Press enter for the following question:
      RSA keys may be between 1024 and 4096 bits long.
      What keysize do you want? (2048)
    4. Press enter for the following question:
      Please specify how long the key should be valid.
               0 = key does not expire
            <n>  = key expires in n days
            <n>w = key expires in n weeks
            <n>m = key expires in n months
            <n>y = key expires in n years
      Key is valid for? (0)
    5. Type y and press enter for the following question:
      Key does not expire at all
      Is this correct? (y/N)
    6. Fill in the Real name appropriately and press enter.
    7. Fill in the Email address appropriately and press enter.
    8. The Comment is optional but don't forget to press enter.
    9. Type o and press enter for the following question:
      Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit?
    10. Fill-in the passphrase appropriately.

The output will be ending with something like the following:

pub   rsa2048 2019-11-27 [SC]
      8C99E30527B112D1CB6D646FE86A4FE7189AADC9
uid                      Real Name <real_email@email.com>
sub   rsa2048 2019-11-27 [E]

The second line is the PGP key ID. Thus from the output above. The key id is:

8C99E30527B112D1CB6D646FE86A4FE7189AADC9

Exporting Your Private Key

The my-secret-key.pgp file generated by this command can be use for signing your binaries.

Run the following command:

gpg --export-secret-keys <KEY_ID> > my-secret-key.pgp

DO NOT SHARE THIS FILE OR COMMIT TO YOUR REPOSITORY.

Publishing Your Public Key

Run the following command:

gpg --send-key <EMAIL_ADDRESS>

Use the email address you've used from generating the key.

Alternative way of Publishing your Public Key

  1. Generate an ASCII-armored PGP key using the following command:
    gpg --armor --export <EMAIL_ADDRESS>

    Use the email address you've used from generating the key.

    The preceding command is exporting your public key in ascii format.

  2. Copy and paste the generated public ID to the following address: http://hkps.pool.sks-keyservers.net/#submit
  3. Click the Submit this key to the keyserver! button.

Validating your Published Public Key

  1. You can validate the upload public key by placing your <EMAIL_ADDRESS> as a Search String from the following address: http://hkps.pool.sks-keyservers.net/#extract.

    This will only work if you submit your keys using the preceding section.

  2. Click the Do the search! button.

Extracting GMail SMTP Certificate using OpenSSL

1a.) For TLS, use the following command:

openssl s_client -connect smtp.gmail.com:587 -starttls smtp

1b.) For SSL, use the following command:

openssl s_client -connect smtp.gmail.com:465

2.) Both  outputs of the preceding commands are long but you we are just interested in the entries that starts with:

-----BEGIN CERTIFICATE-----

and ends with:

-----END CERTIFICATE-----

3.) Copy that block of entries to a new file like smtp.gmail.com.pem.

This file is now the certificate file.

Using Google SMTP with Archiva in Synology

Pre-requisite

Procedure

  1. Open the archiva.xml file found in the following location:
    /volume1/@appstore/Tomcat7/src/conf/Catalina/localhost
  2. Update the Resource entry with the name mail/Session to become the following:
    <Resource name="mail/Session" auth="Container"
          type="javax.mail.Session"
          mail.smtp.host="smtp.gmail.com"
              mail.smtp.port="587"
              mail.smtp.auth="true"
              mail.smtp.user="<USERNAME>"
              password="<PASSWORD>"
              mail.smtp.starttls.enable="true"
              mail.transport.protocol="smtp"/>
    Token Description
    USERNAME Google Account
    PASSWORD Google App Password
  3. Save the updated file and wait for Archiva to restart.

    If you've updated the archiva.xml file and save it, Tomcat will detect it and it will restart the Archiva application.

Artifactory on Ubuntu with MariaDB

Requirement

  • Java 8
  • MariaDB 10.3.x

Preparing MariaDB

  1. Create the database called artdb using the following command:
    CREATE DATABASE artdb CHARACTER SET utf8 COLLATE utf8_bin;
  2. Add artifactory as the user to the newly created database using the following command:
    GRANT ALL on artdb.* TO 'artifactory'@'<HOST>' IDENTIFIED BY '<PASSWORD>';
    FLUSH PRIVILEGES;
    Token Description
    HOST The address of machine housing MariaDB
    PASSWORD The password for the artifactory user.

Installing Artifactory

  1. Add the artifactory repository to your source list.
    echo "deb https://jfrog.bintray.com/artifactory-debs <DISTRIBUTION> main" | sudo tee -a /etc/apt/sources.list
    Token Description
    DISTRIBUTION Use the following command to identify the destribution:

    lsb_release -c

    The sample output for ubuntu bionic distribution:

    Codename:       bionic
  2. Download jfrog public key using the following command:
    curl https://bintray.com/user/downloadSubjectPublicKey?username=jfrog | sudo apt-key add -
  3. Update your package list using the following command:
    sudo apt-get update
  4. Install the oss artifactory using the following command:
    sudo apt-get install jfrog-artifactory-oss

Artifactory Service Commands

Objective Command
Checking service status sudo service artifactory status
Starting the service sudo service artifactory start
Stopping the service sudo service artifactory stop
Restarting the service sudo service artifactory restart

Accessing The Artifactory from the Browser

  1. Use the following address to access the artifactory application:
    http://localhost:8180/artifactory
  2. Use the following default credentails:
    Field Value
    Username admin
    Password password

    It is recommended to change the admin password after installation but you can do it after hooking it to MariaDB.

Using the MariaDB Prepared Earliear

Variable Value
$ARTIFACTORY_HOME /var/opt/jfrog/artifactory
  1. Using the terminal, change the directory to $ARTIFACTORY_HOME/tomcat/lib and execute the following:
    sudo wget https://downloads.mariadb.com/Connectors/java/connector-java-2.4.4/mariadb-java-client-2.4.4.jar

    You can visit https://mariadb.com/downloads/#connectors for a different version of java client.

  2. Copy $ARTIFACTORY_HOME/misc/db/mariadb.properties to $ARTIFACTORY_HOME/etc/db.properties.

    This will replace the default db.properties that is using derby as the database.

  3. Update the following fields in the db.properties:
    Field Value
    url jdbc:mariadb://<HOST>:<PORT>/artdb?characterEncoding=UTF-8&elideSetAutoCommits=true&useSSL=false&useMysqlMetadata=true
    password The password you've used on Preparing MariaDB section.
    Token Value
    HOST The host you've indentified on Preparing MariaDB section.
    PORT This is the port where MariaDB is listening (i.e. 3306 or 3307).
  4. Restart the artifactory service using the following command:
    sudo service artifactory restart
« Older posts Newer posts »