Tuesday, November 24, 2020

HTTPD 2.4 Location Basic Authentication

  1. Customize httpd configuration file

          <Location /restrict/contents>


             Require all denied


             AuthName "Protected Contents"

             AuthType Basic

             AuthUserFile /www/svn/etc/passwd


             <RequireAny>

                 #Require user google

                 Require valid-user

             </RequireAny>


          </Location>

  2. Create password file
    The password is encrypted with MD5, example: 5he#t?+lfRos07zonon7
    $ htpasswd /www/svn/etc/passwd google
  3. Restart/Reload httpd daemon
    # systemctl reload httpd
  4. Encrypt username:password for 'Authorization:' header

    $ echo google:5he#t?+lfRos07zonon7 | base64

    Z29vZ2xlOjVoZSN0PytsZlJvczA3em9ub243Cg==

  5. Call with curl
    curl --location --request POST 'https://www.goweekend.ca/restrict/contents' \
    --header 'X-Authorization-Role: AUTHENTICATED' \
    --header 'Authorization: Basic e3thdXRoLmFjY2Vzcy5rZXl9fTp7e2F1dGguYWNjZXNzLnNlY3JldH19' \
    -H 'Content-Type: application/json' -d '{ "userid":"00019317", "lastName":"Qin"}'

     


Wednesday, November 18, 2020

Tomcat: The Apache Tomcat Connectors - Reference Guide

 

Reference: https://tomcat.apache.org/connectors-doc/reference/workers.html

worker.list=loadbalancer,jk-status


worker.worker1.port=8008

worker.worker1.host=203.18.21.85

worker.worker1.type=ajp13

worker.worker1.lbfactor=1

worker.worker1.socket_keepalive=1

worker.worker1.socket_timeout=300

worker.worker1.ping_mode=A

worker.worker1.ping_timeout=5000


worker.worker2.port=8008

worker.worker2.host=203.18.22.85

worker.worker2.type=ajp13

worker.worker2.lbfactor=1

worker.worker2.socket_keepalive=1

worker.worker2.socket_timeout=300

worker.worker2.ping_mode=A

worker.worker2.ping_timeout=5000


worker.loadbalancer.type=lb

worker.loadbalancer.balance_workers=worker1,worker2

#worker.loadbalancer.balance_workers=off

worker.loadbalancer.sticky_session=1


worker.jk-status.type=status

Sunday, November 15, 2020

Wednesday, November 11, 2020

gpg create key pairs

Reference: https://www.howtogeek.com/427982/how-to-encrypt-and-decrypt-files-with-gpg-on-linux/

Create gpg rings on both sides: you and your client
# List existing keys
gpg --list-keys
# Generate new key
--full-generate-key might not be available in your environment, in the case, you can use --gen-key instead.
$ gpg --full-generate-key
$ gpg --list-keys
# Export private and public keys
gpg --export-secret-key -a "<uid>" > myprivate.key
$ gpg --export --output fei.asc -armor <pub id>
# Export public key in ssh key
gpg --export-ssh-key  <pub id>! 
gpg --export-ssh-key  6352600EF7A9D369A20FF584739E316C0B08E9A5!
gpg --edit-key "user id"


ModuleNotFoundError: No module named 'yaml'

Task:

$ ansible-galaxy init myrole

Problem: 

ModuleNotFoundError: No module named 'yaml'


Solution:

$ pip3 list pyyaml

$ pip3 install pyyaml


Set environment variable PYTHONUSERBASE

$ export PYTHONUSERBASE=/Users/aniu/Library/Python/3.7

$ python3 -m site --user-site

/Users/aniu/Library/Python/3.7/lib/python/site-packages

Friday, November 6, 2020

Mac to erase ubuntu bootable usb

$ gpt destroy /dev/disk2

gpt destroy: unable to open device '/dev/disk2': Permission denied 

Grant full access to terminal in Security and Privacy:



Format the disk with diskutil

$ diskutil zeroDisk /dev/disk2