Tuesday, August 17, 2021

Install Linux Alpine on VMware

 # Install Linux Alpine template:

- setup-alpine

- keyboard us,us

- disk install lvm

- type install sys

reboot


# setup hostname and ip address:

edit file /etc/network/interface


auto eth0

iface eth0 inet static

        address 192.168.2.16

        netmask 255.255.255.0

        gateway 192.168.2.254

        hostname YOUR-HOSTNAME


echo "YOUR-HOSTNAME" > /etc/hostname

hostname -F /etc/hostname


# Set dns:

edit file /etc/resolv.conf

nameserver 8.8.8.8

nameserver 4.4.4.4


reboot


# add repositories /etc/apk/repositories:

edit /etc/apk/repositories


http://dl-cdn.alpinelinux.org/alpine/latest-stable/community/


apk update 

apk upgrade


# create user admin:

adduser admin


# install docker:

apk add docker

apk add docker-compose


# add user admin to docker group:

addgroup admin docker


# start docker on boot:

rc-update add docker boot

service docker start


# install net-snmp:

apk add net-snmp


edit /etc/snmp/snmpd/conf

agentAddress  udp:0.0.0.0:161

rocommunity SNMP_SECRET_KEY  default


# start snmp on boot:

rc-update add snmpd boot

service snmpd start


# install open-vm-tools:

apk add open-vm-tools


# start open-vm-tools on boot:

rc-update add open-vm-tools boot

service open-vm-tools start


# install git:

apk add git


# install vim:

apk add vim


edit /home/${USER}/.vimrc

set tabstop=2

set shiftwidth=2

set softtabstop=2

set expandtab

set visualbell


edit /home/${USER}/.inputrc

set bell-style none #disable bell 


# test snmp services:

snmpwalk -c SNMP_SECRET_KEY -v2c YOUR_SERVER_IPADDRESS

Monday, August 16, 2021

envsubst example

#export TEST=123456

#vim test.txt

test=${TEST}


#envsubst < test.txt

test=123456


#envsubst < test.txt > file.txt

#more file.txt

test=123456

Wednesday, August 4, 2021

How to set per-filetype tab size in vscode

edit settings.json

{

    "[sass]": {

        "editor.tabSize": 2

    },

    "[html]": {

        "editor.tabSize": 4

    },

    "[javascript]": {

        "editor.tabSize": 2

    },

    "[python]": {

        "editor.tabSize": 4

    },

    "[yml]": {

        "editor.tabSize": 2

    },

}

Thursday, July 1, 2021

How to used Github's Personal access token

set global config username and email: 
git config --global user.name "username"
git config --global user.email "email address" 

show config:
git config -l 

store credential in cache: 
git config --global credential.helper cache 

ex. 7 days
git config --global credential.helper 'cache --timeout=604800' 

1 day 86400 second
7 day 604800 second
30 day 2592000 second

remove credential:
git config --global --unset credetial.helper

Monday, May 24, 2021

Tuesday, May 18, 2021

Install docker on Linux Alpine 3.13.5

Install Docker:

$ apk --no-cache add --repository http://dl-cdn.alpinelinux.org/alpine/edge/main libseccomp

$ apk --no-cache add --repository http://dl-cdn.alpinelinux.org/alpine/edge/community docker


Add User to Docker Group:

addgroup itcadmin docker


Start Docker on Boot:

rc-update add docker boot

service docker start


Install docker-compose:

uncoment

#http://dl-cdn.alpinelinux.org/alpine/v3.13/community

and

#http://dl-cdn.alpinelinux.org/alpine/v3.13/community


EX. 

alpine-tpl:/etc/apk# more repositories

#/media/cdrom/apks

http://dl-cdn.alpinelinux.org/alpine/v3.13/main

http://dl-cdn.alpinelinux.org/alpine/v3.13/community

#http://dl-cdn.alpinelinux.org/alpine/edge/main

#http://dl-cdn.alpinelinux.org/alpine/edge/community

#http://dl-cdn.alpinelinux.org/alpine/edge/testing


apk add docker-compose

Friday, April 30, 2021

Freeradius Linelog

freeradius linelog


edit file /etc/freeradius/modules/linelog


linelog log_postauth_json {

        format = "%t linelog_postauth \%Packet-Type non reconnu for %{User-Name} (%{Packet-Type})"

        filename = ${logdir}/linelog/linelog_json.log

        syslog_facility = local3

        syslog_serverity = info

        permissions = 0600

        reference = "messages.%{%{reply:Packet-Type}:-format}"

        messages {

                Access-Reject = "{\"Datetime\":\"%t\",\"Module_Name\":\"linelog_postauth\",\"Packet-Type\":\"%{reply:Packet-Type}\",\"User-Name\":\"%{User-Name}\",\"Realm\":\"%{Realm}\",\"NAS-IP-Address\":\"%{NAS-IP-Address}\",\"NAS-Port\":\"%{NAS-Port}\",\"Service-Type\":\"%{Service-Type}\",\"Framed-MTU\":\"%{Framed-MTU}\",\"State\":\"%{State}\",\"Class\":\"%{Class}\",\"Vendor-Specific\":\"%{Vendor-Specific}\",\"Session-Timeout\":\"%{Session-Timeout}\",\"Idle-Timeout\":\"%{Idle-Timeout}\",\"Termination-Action\":\"%{Termination-Action}\",\"Called-Station-Id\":\"%{Called-Station-Id}\",\"Calling-Station-Id\":\"%{Calling-Station-Id}\",\"NAS-Identifier\":\"%{NAS-Identifier}\",\"Proxy-State\":\"%{Proxy-State}\",\"Login-LAT-Service\":\"%{Login-LAT-Service}\",\"Login-LAT-Node\":\"%{Login-LAT-Node}\",\"Login-LAT-Group\":\"%{Login-LAT-Group}\",\"Framed-AppleTalk-Link\":\"%{Framed-AppleTalk-Link}\",\"Framed-AppleTalk-Network\":\"%{Framed-AppleTalk-Network}\",\"Framed-AppleTalk-Zone\":\"%{Framed-AppleTalk-Zone}\",\"CHAP-Challenge\":\"%{CHAP-Challenge}\",\"NAS-Port-Type\":\"%{NAS-Port-Type}\",\"Port-Limit\":\"%{Port-Limit}\",\"Login-LAT-Port\":\"%{Login-LAT-Port}\"}"

                Access-Challenge = "{\"Datetime\":\"%t\",\"Module_Name\":\"linelog_postauth\",\"Packet-Type\":\"%{reply:Packet-Type}\",\"User-Name\":\"%{User-Name}\",\"Realm\":\"%{Realm}\",\"NAS-IP-Address\":\"%{NAS-IP-Address}\",\"NAS-Port\":\"%{NAS-Port}\",\"Service-Type\":\"%{Service-Type}\",\"Framed-Protocol\":\"%{Framed-Protocol}\",\"Framed-IP-Address\":\"%{Framed-IP-Address}\",\"Framed-IP-Netmask\":\"%{Framed-IP-Netmask}\",\"Framed-Routing\":\"%{Framed-Routing}\",\"Filter-Id\":\"%{Filter-Id}\",\"Framed-MTU\":\"%{Framed-MTU}\",\"Framed-Compression\":\"%{Framed-Compression}\",\"Login-IP-Host\":\"%{Login-IP-Host}\",\"Login-Service\":\"%{Login-Service}\",\"Login-TCP-Port\":\"%{Login-TCP-Port}\",\"Reply-Message\":\"%{Reply-Message}\",\"Callback-Number\":\"%{Callback-Number}\",\"Callback-Id\":\"%{Callback-Id}\",\"Framed-Route\":\"%{Framed-Route}\",\"Framed-IPX-Network\":\"%{Framed-IPX-Network}\",\"State\":\"%{State}\",\"Class\":\"%{Class}\",\"Vendor-Specific\":\"%{Vendor-Specific}\",\"Session-Timeout\":\"%{Session-Timeout}\",\"Idle-Timeout\":\"%{Idle-Timeout}\",\"Termination-Action\":\"%{Termination-Action}\",\"Called-Station-Id\":\"%{Called-Station-Id}\",\"Calling-Station-Id\":\"%{Calling-Station-Id}\",\"NAS-Identifier\":\"%{NAS-Identifier}\",\"Proxy-State\":\"%{Proxy-State}\",\"Login-LAT-Service\":\"%{Login-LAT-Service}\",\"Login-LAT-Node\":\"%{Login-LAT-Node}\",\"Login-LAT-Group\":\"%{Login-LAT-Group}\",\"Framed-AppleTalk-Link\":\"%{Framed-AppleTalk-Link}\",\"Framed-AppleTalk-Network\":\"%{Framed-AppleTalk-Network}\",\"Framed-AppleTalk-Zone\":\"%{Framed-AppleTalk-Zone}\",\"CHAP-Challenge\":\"%{CHAP-Challenge}\",\"NAS-Port-Type\":\"%{NAS-Port-Type}\",\"Port-Limit\":\"%{Port-Limit}\",\"Login-LAT-Port\":\"%{Login-LAT-Port}\"}"

                Access-Accept = "{\"Datetime\":\"%t\",\"Module_Name\":\"linelog_postauth\",\"Packet-Type\":\"%{reply:Packet-Type}\",\"User-Name\":\"%{User-Name}\",\"Realm\":\"%{Realm}\",\"NAS-IP-Address\":\"%{NAS-IP-Address}\",\"NAS-Port\":\"%{NAS-Port}\",\"Service-Type\":\"%{Service-Type}\",\"Framed-MTU\":\"%{Framed-MTU}\",\"Login-IP-Host\":\"%{Login-IP-Host}\",\"Login-Service\":\"%{Login-Service}\",\"Login-TCP-Port\":\"%{Login-TCP-Port}\",\"Reply-Message\":\"%{Reply-Message}\",\"Callback-Number\":\"%{Callback-Number}\",\"Callback-Id\":\"%{Callback-Id}\",\"Framed-Route\":\"%{Framed-Route}\",\"Framed-IPX-Network\":\"%{Framed-IPX-Network}\",\"State\":\"%{State}\",\"Class\":\"%{Class}\",\"Vendor-Specific\":\"%{Vendor-Specific}\",\"Session-Timeout\":\"%{Session-Timeout}\",\"Idle-Timeout\":\"%{Idle-Timeout}\",\"Termination-Action\":\"%{Termination-Action}\",\"Called-Station-Id\":\"%{Called-Station-Id}\",\"Calling-Station-Id\":\"%{Calling-Station-Id}\",\"NAS-Identifier\":\"%{NAS-Identifier}\",\"Proxy-State\":\"%{Proxy-State}\",\"Login-LAT-Service\":\"%{Login-LAT-Service}\",\"Login-LAT-Node\":\"%{Login-LAT-Node}\",\"Login-LAT-Group\":\"%{Login-LAT-Group}\",\"Framed-AppleTalk-Link\":\"%{Framed-AppleTalk-Link}\",\"Framed-AppleTalk-Network\":\"%{Framed-AppleTalk-Network}\",\"Framed-AppleTalk-Zone\":\"%{Framed-AppleTalk-Zone}\",\"CHAP-Challenge\":\"%{CHAP-Challenge}\",\"NAS-Port-Type\":\"%{NAS-Port-Type}\",\"Port-Limit\":\"%{Port-Limit}\",\"Login-LAT-Port\":\"%{Login-LAT-Port}\",\"VLAN\":\"%{Tunnel-Private-Group-ID:0}\"}"

    }

}


edit site enable /etc/freeradius/site-enabled/default


post-auth {

    log_postauth_json


    Post-Auth-Type REJECT {

        log_postauth_json

    }

}


create log rotate policy /etc/logrotate.d/linelog


/var/log/freeradius/linelog/linelog_json.log


{

    rotate 99

    daily

    dateext

    missingok

    notifempty

    delaycompress

    compress

    sharedscripts

    postrotate

        invoke-rc.d rsyslog rotate > /dev/null

    endscript

}

ALCATEL 6900

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