Skip to content

Latest commit

 

History

History
288 lines (251 loc) · 7.41 KB

File metadata and controls

288 lines (251 loc) · 7.41 KB

Enable WSL (Enable Windows Subsystem for Linux)

If you are not already using Linux on Windows 10, you must enable WSL 1 with these steps:

  1. Open Start on Windows 10.
  2. Search for Turn Windows features on or off and click the top result to open the app.

Windows Setup

  1. Disable Managed App Execution for Python - Stop Python from opening the Microsoft store
  2. Install Python
  3. Install AWS CLI
  4. Install Chocolatey
  5. Install gossamer
    a. Gossamer3 Config Step 1: On PowerShell execute: configure gossamer3
    b. Gossamer3 Config Step 2: Edit below .gossamer3.yaml file to validate and update Gossamers3 configuration

VS Code Links

VS Code / WSL Tutorial
VS Code / Tips & Tricks

Install Some Utilities

# Run Powershell as Administrator
choco install jq -y
choco install yq -y
choco install curl -y
choco install grep -y
choco install wget -y
choco install zip -y
choco install gzip -y
choco install sed -y
choco install awk -y

Fix python3 in PS

# PowerShell
cd $HOME/AppData\Local\Programs\Python\Python311\
New-Item -Type SymbolicLink -Path python3.exe -Target python.exe

Gosammer3 Config file

SSO: 50334532 should be your SSO (Employee ID) for both path of the file and username inside the file.
File: $HOME/.gossamer3.yaml

- name: default
  url: https://fssfed.ge.com/fss
  username: "503345432"
  provider: Ping
  mfa: Auto
  mfa_device: ""
  mfa_prompt: false
  skip_verify: false
  timeout: 10
  aws_urn: urn:amazon:webservices:mfa-extended
  aws_session_duration: 43200
  aws_profile: geadmin
  role_arn: arn:aws:iam::589623221417:role/cs/p-jump-support
  region: ""
  http_attempts_count: ""
  http_retry_delay: ""
  
- name: gov-mfa
  url: https://fssfed.ge.com/fss
  username: "503345432"
  provider: Ping
  mfa: Auto
  mfa_device: ""
  mfa_prompt: false
  skip_verify: false
  timeout: 10
  aws_urn: urn:amazon:webservices:govcloudmfa
  aws_session_duration: 3600
  aws_profile: gov-mfa
  role_arn: ""
  region: us-gov-east-1
  http_attempts_count: ""
  http_retry_delay: ""

Sample Gossamer3 Bulk Logine file

# Windows
#     $HOME/access-roles.yml
# Linux:  
#     ~/access-roles.yml
roles:
  # GR-Limited 589623221417 [geadmin] Corporate CoreTech
  - primary_role_arn: arn:aws:iam::589623221417:role/cs/p-jump-engineering
    profile: GEAdmin
    region: us-east-1
    aws_session_duration: 43200 # Optional aws_session_duration per primary role

    assume_roles:
      # GR-Standard 432375862099 [mac-co-dev] Corporate CoreTech
      - role_arn: arn:aws:iam::432375862099:role/cs/p-engineering
        profile: mac-co-dev

      # GR-Standard 716721748482 [mae-co-dev] Corporate CoreTech
      - role_arn: arn:aws:iam::716721748482:role/cs/p-engineering
        profile: mae-co-dev

      # GR-Limited 295439606565 [mae-co-dev-ext] Corporate CoreTech
      - role_arn: arn:aws:iam::295439606565:role/cs/p-engineering
        profile: mae-co-dev-ext

      # GR-Standard 432403552778 [mas-co-dev] Corporate CoreTech
      - role_arn: arn:aws:iam::432403552778:role/cs/p-engineering
        profile: mas-co-dev

Check the “Windows Subsystem for Linux” option.

Install WSL

# Install WSL
wsl --install
wsl --version
wsl -–update
wsl --list --online
wsl -–install -d Ubuntu-22.04

Restart your computer

# PowerShell
wsl --update

Open Ubuntu-22.04

sudo apt update
sudo apt install python-is-python3
sudo apt install -y jq
sudo apt install -y rename
# install or upgrade python 
sudo apt install -y curl
sudo apt install -y grep
sudo apt install -y gzip
sudo apt install -y wget
sudo apt install -y zip
pip install yq
# https://linuxconfig.org/counting-lines-of-code-with-cloc
# https://github.com/AlDanial/cloc
sudo apt install cloc # Count Line of Codes

Pip Freeze List - requirements.txt

ansible==7.4.0
ansible-core==2.14.4
argcomplete==3.0.8
boto3==1.26.104
botocore==1.29.106
certifi==2022.12.7
cffi==1.15.1
charset-normalizer==3.1.0
colorama==0.4.4
cryptography==40.0.1
docopt==0.6.2
docutils==0.16
execnet==1.9.0
idna==3.4
iniconfig==2.0.0
Jinja2==3.1.2
jmespath==1.0.1
markdown-it-py==2.2.0
MarkupSafe==2.1.2
mdurl==0.1.2
numpy==1.24.3
packaging==23.1
pandas==2.0.1
pluggy==1.0.0
pyasn1==0.4.8
pycparser==2.21
Pygments==2.15.0
pynamo==1.2.1604553482
pytest==7.3.1
pytest-dependency==0.5.1
pytest-json-report==1.5.0
pytest-metadata==2.0.4
pytest-xdist==3.2.1
python-dateutil==2.8.2
pytz==2023.3
PyYAML==5.4.1
requests==2.28.2
resolvelib==0.8.1
rich==13.4.1
rsa==4.7.2
s3transfer==0.6.0
six==1.16.0
tomlkit==0.11.8
tzdata==2023.3
urllib3==1.26.15
XlsxWriter==3.0.9
xmltodict==0.13.0
yq==3.2.2

Uninstalling the AWS CLI version 2

Install AWS CLI version 2

Stop firewall - MyApps Anywhere

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

Gossamer3

Gossamer3 Installation on Linux

CURRENT_VERSION=3.1.7
wget https://github.com/GESkunkworks/gossamer3/releases/download/v${CURRENT_VERSION}/gossamer3_${CURRENT_VERSION}_linux_amd64.tar.gz
tar -xzvf gossamer3_${CURRENT_VERSION}_linux_amd64.tar.gz -C ~/.local/bin
chmod u+x ~/.local/bin/gossamer3

sudo apt install -y pass

Certs

# PowerShell
cd $HOME
python ge-cert.py
# Linux a
curl https://static.gecirtnotification.com/browser_remediation/packages/GE_Dev_External_Root_CA_2_1.crt -o ~/gecert.pem
cat ~/gecert.pem >> ~/aws/dist/awscli/botocore/cacert.pem

# CURL_CA_BUNDLE setup - add below to .bashrc
export CURL_CA_BUNDLE=~/aws/dist/awscli/botocore/cacert.pem

Fix python3 in PS

# PowerShell
get-command -all python | awk '{print $4}' | grep 'python'
# ex: cd .$HOME\AppData\Local\Programs\Python\Python311\
New-Item -Type SymbolicLink -Path python3.exe -Target python.exe

Ubuntu Customization

nano ~/.bashrc

# go to the end of ~/.bashrc and add below

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

if [ "$color_prompt" = yes ]; then
    PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\n\[\033[00;35m\]\$(git_branch)\[\033[00m\]\$"
fi

# on ls sort directories first
alias ls="ls --color=auto --group-directories-first"
alias cls=clear

# OTHER_WRITABLE 34;42 # blue;green        dir that is other-writable (o+w) and not sticky
# OTHER_WRITABLE 01;35 # bold;purple;black dir that is other-writable (o+w) and not sticky
LS_COLORS+=':ow=01;35'

Git Global Config to Prevent changing LF to CRLF

# PowerShell
git config --global core.autocrlf false

# Linux Shell
git config --global core.autocrlf false

Count Lines of Code Usage

# Report current directoty by File & by Language
for d in ./*/ ; do (cd "$d" && echo "$d" && cloc --vcs git -by-file-by-lang); done

# Report current directory 
for d in ./*/ ; do (cd "$d" && echo "$d" && cloc --vcs git); done
cloc ./
# Report current directory