Monday, December 21, 2020

How to access from local network in WSL2

add port: 

netsh interface portproxy add v4tov4 listenport=3000 listenaddress=0.0.0.0 connectport=3000 connectaddress=172.20.216.249


delete port:

netsh interface portproxy delete v4tov4 listenport=3000 listenaddress=0.0.0.0


show port:

netsh interface portproxy show all


ex.

PS C:\Windows\system32> netsh interface portproxy show all

Listen on ipv4:             Connect to ipv4:


Address         Port        Address         Port

--------------- ----------  --------------- ----------

0.0.0.0         3000        172.20.216.249  3000

0.0.0.0         8080        172.20.216.249  8080


Monday, December 7, 2020

PowerShell Connections for Office365 Administrators

Office 365/Azure AD

Microsoft Online Services Sign-in Assistant for IT Professionals 

PS C:\>Install-Module MSOnline

PS C:\>$credential = Get-Credential

PS C:\>Connect-MsolService -Credential $Credential


Azure AD

PS C:\>Install-Module AzureAD

PS C:\>Connect-AzureAD


Exchange Online

PS C:\>$credential = Get-Credential

PS C:\>$exosession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid -Credential $credential -Authentication Basic –AllowRedirection

PS C:\>Import-PSSession $exosession


Microsoft Teams

PS C:\>Install-Module -Name MicrosoftTeams

PS C:\>Install-Module -Name MicrosoftTeams -AllowClobber

PS C:\>Connect-MicrosoftTeams


Skype for Business Online

Skype for Business Online PowerShell Module 

PS C:\>$credential = Get-Credential

PS C:\>$skypesession = New-CsOnlineSession -Credential $credential

PS C:\>Import-PSSession $skypesession


SharePoint Online

SharePoint Online Management Shell

PS C:\>$Credential = Get-Credential

PS C:\>Connect-SPOService -url https://yourtenantname-admin.sharepoint.com -Credential $credential

ex. Connect-SPOService -url https://my365-admin.sharepoint.com -Credential $credential

PS C:\>Get-Command -Noun SPO*


Security and Compliance Center

PS C:\>$credential = Get-Credential

PS C:\>$ccsession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $Credential -Authentication Basic -AllowRedirection

PS C:\>Import-PSSession $ccsession


Tuesday, November 24, 2020

Error opening specified endpoint "udp:127.0.0.1:161" (net-snmp) ALPINE LINUX

Error opening specified endpoint "udp:127.0.0.1:161" (net-snmp) ALPINE LINUX

#vi /etc/snmp/snmpd.conf

agentAddress  SERVER_IP_ADDRESS

or

#vi /etc/snmp/snmpd.conf

agentAddress  udp:161


#rc-update add snmpd default

#/etc/init.d/snmpd start


Monday, November 16, 2020

Reset GlobalProtect Agent

:stop server/agent palo

launchctl unload /Library/LaunchAgents/com.paloaltonetworks.gp.pangps.plist

launchctl unload /Library/LaunchAgents/com.paloaltonetworks.gp.pangpa.plist


:start server/agent palo

launchctl load /Library/LaunchAgents/com.paloaltonetworks.gp.pangps.plist

launchctl load /Library/LaunchAgents/com.paloaltonetworks.gp.pangpa.plist

Wednesday, October 28, 2020

GET Let's Encrypts Certificates (dns)

$sudo apt install certbot

$sudo certbot certonly \

  --server https://acme-v02.api.letsencrypt.org/directory \

  --manual --preferred-challenges dns \

  -d your.domain.com

## Add records TXT _acme-challenge.your.domain.com

$nslookup -type=TXT _acme-challenge.your.domain.com

#Certs Path

/etc/letsencrypt/live/

Tuesday, September 15, 2020

Show GIT Branch on Bash

ubuntu edit .bashrc
alpine linux .profile

show_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}

export PS1="\u@\h \[\e[32m\]\w \[\e[91m\]\$(show_git_branch)\[\e[00m\] $ "

Tuesday, September 1, 2020

Unable to 'apt update' my Ubuntu 19.04

sudo sed -i -re 's/([a-z]{2}\.)?th.archive.ubuntu.com|archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list

Friday, August 28, 2020

CPU and Memory OID Alcatel 6400

Memory:

name: healthDeviceMemoryLatest

oid: .1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.9.0


CPU:

name: healthDeviceCpuLatest

oid: .1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.13.0

Thursday, August 27, 2020

Pretty print json Format in BASH terminal

Pretty print json Format in BASH terminal

ex:

curl -X GET http://localhost:8001 | python3 -m json.tool


create alias in .bashrc :

alias pprint='python3 -m json.tool'


ex:

curl -X GET http://localhost:8001 | pprint


Friday, August 7, 2020

How to change the Docker default subnet IP address

create file : /etc/docker/daemon.json

{

  "bip": "11.22.33.1/24"

}


{

    "default-address-pools": [

            {

                "base": "10.10.0.0/16",

                "size": 24

            }

        ]

}

restart docker services



Custom PS1 Linux Terminal

ex:

export PS1="\[\033[36m\]\D{%Y-%m-%d-%I:%M%p}\[\033[00m\] \[\033[95m\]\u@$WSL_DISTRO_NAME\[\033[00m\]:\[\033[35m\]\w\[\033[00m\] $ "

export PS1="\[\033[33m\]\D{%Y-%m-%d-%I:%M%p}\[\033[00m\] \[\033[32m\]\u@$WSL_DISTRO_NAME\[\033[00m\]:\[\033[36m\]\w\[\033[00m\] $ "

Thursday, August 6, 2020

OGG-01004, OCI Error ORA-04098: trigger 'MEIS.ZONE_TG' is invalid and failed re-validation (status = 4098)

OGG-01004, OCI Error ORA-04098: trigger 'MEIS.ZONE_TG' is invalid and failed re-validation (status = 4098)

Cause:

Triggers are causing issue while data is being loaded to table.



Resolution:

You could use the option “SUPRESSTRIGGERS” in the Replicat processes. 
If it still abends the Replicat process, 
you may have to disable the trigger in the database and restart the process.

sql> alter trigger ‘<User>.<Trigger>’ disable;

Ex:

SQL> alter trigger MEIS.ZONE_TG disable;

Wednesday, July 8, 2020

Oracle Golden Gate Error : Fatal error executing DDL replication: error [Error code [955], ORA-00955

ex: 

2020-07-08 10:32:56  ERROR   OGG-00519  Oracle GoldenGate Delivery for Oracle, rmeis.prm:  Fatal error executing DDL replication: error [Error code [955], ORA-00955: มีออบเจกต์อื่นที่ใช้ชื่อนี้แล้ว
SQL alter table "SERVICES_APP"."CLIENTUSESERVICE"
  add constraint PKCLIENTUSESERVICE primary key (IDCLIENT, SERVICENAME, SERVICES, STARTDATE)
  using index
  tablespace USERS
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 64K
    next 1M
    minextents 1
    maxextents unlimited
  )
  /*

Check Constraints:


SELECT CONSTRAINT_NAME, TABLE_NAME, COLUMN_NAMEFROMDBA_CONS_COLUMNSWHEREOWNER LIKE 'SERVICES_APP'ANDTABLE_NAME LIKE 'CLIENTUSESERVICE'


SQL> l
  1  SELECT CONSTRAINT_NAME, TABLE_NAME, COLUMN_NAME
  2  FROM
  3  DBA_CONS_COLUMNS
  4  WHERE
  5  OWNER LIKE 'SERVICES_APP'
  6  AND
  7* TABLE_NAME LIKE 'CLIENTUSESERVICE'
SQL> /

CONSTRAINT_NAME                TABLE_NAME                     COLUMN_NAME
------------------------------ ------------------------------ --------------------
SYS_C0018194                   CLIENTUSESERVICE               IDCLIENT
SYS_C0018196                   CLIENTUSESERVICE               SERVICES
SYS_C0018195                   CLIENTUSESERVICE               SERVICENAME
FKCLIENTUSESERVICE             CLIENTUSESERVICE               IDCLIENT

if constraint SERVICES_APP.PKCLIENTUSESERVICE doesn't exists


check Indexes:

SELECT INDEX_NAME, TABLE_NAMEFROMDBA_INDEXESWHEREOWNER LIKE 'SERVICES_APP'ANDTABLE_NAME LIKE 'CLIENTUSESERVICE'

SQL> l
  1  SELECT INDEX_NAME, TABLE_NAME
  2  FROM
  3  DBA_INDEXES
  4  WHERE
  5  OWNER LIKE 'SERVICES_APP'
  6  AND
  7* TABLE_NAME LIKE 'CLIENTUSESERVICE'
SQL> /

INDEX_NAME                     TABLE_NAME
------------------------------ ------------------------------
PKCLIENTUSESERVICE             CLIENTUSESERVICE



if index SERVICES_APP.PKCLIENTUSESERVICE exists
drop index and restart Oracle Goldent Gate

DROP INDEX SERVICES_APP.PKCLIENTUSESERVICE;


Thursday, June 11, 2020

Office365 Powershell example

https://docs.microsoft.com/en-us/office365/enterprise/powershell/connect-to-office-365-powershell#connect-with-the-azure-active-directory-powershell-for-graph-module

Install-Module MSOnline

Connect-MsolService

Get-MsolUser –All

Get-MsolUser -UserPrincipalName admin@demo.onmicrosoft.com

Get-MsolUser –DomainName demo.onmicrosoft.com

Get-MsolUser –UnlicensedUsersOnly

Get-MsolUser -SearchString "user@demo.onmicrosoft.com" | fl IsLicensed, Licenses, ObjectId


IsLicensed : True
Licenses   : {nida365:STANDARDWOFFPACK_IW_FACULTY}
ObjectId   : 37787efb-8c3e-449f-9799-9c636c26a554



(Get-MsolUser -UserPrincipalName user@demo.onmicrosoft.com).Licenses.servicestatus

Set-MsolUserLicense -UserPrincipalName user@demo.onmicrosoft.com -RemoveLicenses demo365:POWER_BI_STANDARD, demo365:POWERAPPS_INDIVIDUAL_USER, demo365:STANDARDWOFFPACK_IW_FACULTY


Set-MsolUserLicense -UserPrincipalName user@demo.onmicrosoft.com -AddLicenses demo365:POWER_BI_STANDARD, demo365:POWERAPPS_INDIVIDUAL_USER, demo365:STANDARDWOFFPACK_IW_FACULTY

(Get-MsolUser -UserPrincipalName user@demo.onmicrosoft.com).Licenses.servicestatus

Thursday, May 28, 2020

Set TimeZone Ubuntu 20

check TimeZone:
$ timedatectl

List TimeZone:
$ timedatectl list-timezones | grep Bangkok

Set TimeZone:
$ sudo timedatectl set-timezone Asia/Bangkok

Check TimeZone:
$ timedatectl


How to fix Ubuntu 20.04 error "sda: failed to get udev uid: Invalid argument"

```
sda: add missing path
sda: failed to get udev uid: Invalid argument
sda: failed to get sysfs uid: Invalid argument
sda: failed to get sgio uid: No such file or directory
```

VM option -> Advance -> Configuration Parameter 

Add Parameter 

disk.EnableUUID=TRUE

How to fix ssh returns “Bad owner or permissions on ~/.ssh/config”

chmod 600 ~/.ssh/config
chown $USER ~/.ssh/config

Monday, April 13, 2020

Monday, April 6, 2020

Remote Desktop "This could be due to CredSSP encryption oracle remediation."

- ไปที่ run พิมพ์ CMD กด Ctrl+Shift+Enter (เป็นการเข้า cmd administrotor mode)
- พิมพ์คำสั่ง REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters\ /v AllowEncryptionOracle /t REG_DWORD /d 2 ลงไป
- กด enter
- restart computer

Monday, March 9, 2020

Thursday, March 5, 2020

KONG & KONGA

#!/bin/sh
export VERSION=latest
docker network create kong-net
docker run -d --name kong-database \
     --network=kong-net \
     -p 5432:5432 \
     -e "POSTGRES_USER=kong" \
     -e "POSTGRES_DB=kong" \
     -e "POSTGRES_HOST_AUTH_METHOD=trust" \
     postgres:9.6

sleep 5

docker run --rm \
     --network=kong-net \
     -e "KONG_DATABASE=postgres" \
     -e "KONG_PG_HOST=kong-database" \
     kong:$VERSION kong migrations bootstrap

docker run -d --name kong \
     --network=kong-net \
     -e "KONG_DATABASE=postgres" \
     -e "KONG_PG_HOST=kong-database" \
     -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
     -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
     -e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
     -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \
     -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \
     -p 8000:8000 \
     -p 8443:8443 \
     -p 8001:8001 \
     -p 8444:8444 \
     kong:$VERSION

docker run -d --name konga-database \
     --network=kong-net \
     -e "POSTGRES_USER=kong" \
     -e "POSTGRES_DB=kong" \
     -e "POSTGRES_HOST_AUTH_METHOD=trust" \
     postgres:9.6

sleep 5

docker run --rm --network=kong-net pantsel/konga -c prepare -a postgres -u postgresql://kong@konga-database:5432/konga_db
docker run -d -p 1337:1337 \
     --network=kong-net \
     -e "DB_ADAPTER=postgres" \
     -e "DB_HOST=konga-database" \
     -e "DB_USER=kong" \
     -e "DB_DATABASE=konga_db" \
     -e "KONGA_HOOK_TIMEOUT=120000" \
     -e "NODE_ENV=production" \
     --name konga \
     pantsel/konga

Monitor Docker Services

docker volume create portainer_data

docker run \
    --name portainer-docker-info \
    --restart always\
    -d \
    -p 80:9000 \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v portainer_data:/data \
    portainer/portainer

Tuesday, March 3, 2020

netsh portproxy WSL2

netsh interface portproxy show all
netsh interface portproxy add v4tov4 listenport=HOST_PublishPort listenaddress=0.0.0.0 connectport=WSL_Port connectaddress=WSL_IPAddress

ex:
netsh interface portproxy add v4tov4 listenport=8000 listenaddress=0.0.0.0 connectport=8000 connectaddress=172.28.81.216
netsh interface portproxy add v4tov4 listenport=8080 listenaddress=0.0.0.0 connectport=8080 connectaddress=172.28.81.216
netsh interface portproxy add v4tov4 listenport=3000 listenaddress=0.0.0.0 connectport=3000 connectaddress=172.28.81.216
netsh interface portproxy add v4tov4 listenport=5000 listenaddress=0.0.0.0 connectport=5000 connectaddress=172.28.81.216

Wednesday, February 26, 2020

Nginx redirect from http to https non-standard Port

create nginx config file on /etc/nginx/conf.d
ex. /etc/nginx/conf.d/redirect.conf


server {

        listen 80;
        server_name localhost;
        return 301 https://$host$request_uri;
}

server {

        listen 443 ssl;
        server_name localhost;
        ssl_certificate /etc/nginx/ssl/certs.crt;
        ssl_certificate_key /etc/nginx/ssl/key.key;
        ssl_dhparam /etc/nginx/ssl/dhparam.pem;
        ssl_ciphers 'kEECDH+ECDSA+AES128 kEECDH+ECDSA+AES256 kEECDH+AES128 kEECDH+AES256 kEDH+AES128 kEDH+AES256 DES-CBC3-SHA +SHA !aNULL !eNULL !LOW !kECDH !DSS !MD5 !RC4 !EXP !PSK !SRP !CAMELLIA !SEED';
        ssl_protocols TLSv1.2;
        ssl_session_timeout 1d;
        ssl_session_cache shared:SSL:50m;
        ssl_stapling on;
        ssl_stapling_verify on;
        add_header Strict-Transport-Security max-age=15768000;
return 301 $scheme://$host:6081$request_uri;
}

server {

        listen 6081 ssl;
        server_name localhost;
        ssl_certificate /etc/nginx/ssl/certs.crt;
        ssl_certificate_key /etc/nginx/ssl/key.key;
        ssl_dhparam /etc/nginx/ssl/dhparam.pem;
        ssl_ciphers 'kEECDH+ECDSA+AES128 kEECDH+ECDSA+AES256 kEECDH+AES128 kEECDH+AES256 kEDH+AES128 kEDH+AES256 DES-CBC3-SHA +SHA !aNULL !eNULL !LOW !kECDH !DSS !MD5 !RC4 !EXP !PSK !SRP !CAMELLIA !SEED';
        ssl_protocols TLSv1.2;
        ssl_session_timeout 1d;
        ssl_session_cache shared:SSL:50m;
        ssl_stapling on;
        ssl_stapling_verify on;
        add_header Strict-Transport-Security max-age=15768000;
        location / {
                include /etc/nginx/conf.d/common_location.conf;
                root /usr/share/nginx/html;
                index index.html index.htm;
                # proxy_pass http://11.11.11.250:5000; #pass_to_backendserver
        
        }

}

Friday, January 17, 2020

Using Vue Variable in Jinja Python Flask


- Using {% raw %} directive
ex.

<div id="app">
{% raw %}
{{ var_from_vue }}
{% endraw %}
</div>

- Using Vue delemiters in Vue Instant
ex.

var app = new Vue({
    el: '#app',
    data: {
        v1: 'variable 1'
    },
    delimiters: ['[[', ']]'] 
})

- Custom Directive in Python Flask Jinja
ex.

app = Flask(__name__)

jinja_options = app.jinja_options.copy()
jinja.options.update(dict(
    variable_start_string='[[',
    variable_end_string=']]'
))
app.jinja_options = jinja_options

ALCATEL 6900

write memory copy running certified reload from working no rollback-timeout