Security Layers

Core Security Principles

graph LR;

A[Confidenciality];
B[Integrity];
C[Availability];

A --- B;
B --- C;
C --- A;
  • CIA triad (iron triangle):
    • Confidenciality: avoid unauthorized users access to information.
      • Encryption keys: the unauthorized gets “cypher text” (scrambled data).
      • Data and states encryption:
        • At Rest (stored).
        • In transit (protocol in communication).
        • User (application, hence the authorized software list).
      • Access control to computer (log in). Principle of least prviledge.
    • Integrity: data has not been modified.
      • Access control: write permissions.
      • Version control: recover different versions.
      • Hash functions: no information is modified on transit.
    • Availability: servers “are alive”.
      • Redundancy.
      • Fault tolerance: back-up.

Threats vulnerabilities and and exploits

  • Threats: event with potential for adverse effect (virus, phishing, DDoS).
    • Threat actors: individuals who pose a threat.
      • Script kiddies: no skills.
      • Malicious insiders: employees or contractors.
      • Hacktivist: perceived idiologist.
      • State sponsored: funded by governments (APT: Advance Persistent threats).
      • Cyberterrorist: Proliferate fear and discord.
  • Vulnerabilities: weakness which allows threat to materialize.
    • Passwords: weak passwords are prone to attacks.
    • Legacy systems: lack of support and patching.
    • Default or weak configurations: easily discoverable.
    • Unpatched systems: missing security updates.
    • Unsecure protocols: unauthorized data access.
  • Exploits: technique or tool used againts weaknesses.
    • Social engineering: soliciting information from authorized user.
    • Malware: gain access through unathorized software.
    • “Man in the middle” or “on path attack”: eavesdropping or unathorized access.
    • Password attacks: gain access to password protected systems.
    • Zero-day: recently discovered vulnerability, “and nobody knows about it”, plus lifecycle path takes time.

Risks and impact

  • Concepts:
    • Risk: probability of a loss, damage, compromise or exposure of system (not always malicious, it can be accidental).
      • Breach: unauthorized access (violating security policy).
    • Impact: Extent of a risk if it materializes.
  • Risk management: risk matrix to meassure impact (likelihood vs severity). Priority on mitigation.
    • NIST: guidance with risk management framework.
      1. Prepare (define essential activities).
      2. Categorize (what we have?).
      3. Select (select set of controls).
      4. Implement (implementation and documentation of controls).
      5. Assess (do these controls work for us?).
      6. Authorize (someone in charge).
      7. Monitor (monitor the controls, in order to evolve.

Security by design, not by an afterthought.

Physical security

  • Outside the building:
    • Fencing: guards (someone who can react), CCTV (Close Caption TV + cameras), lights, locks, barrciades, ballards.
    • Architecture reinforcements.
    • Startegic positioning of trees.
  • Inside:
    • Access Control recepcionist
    • Cameras (and motion sensors).
    • Architecture: doors swinging inside (takes longer to get out), furniture positioning, secure access (“demarcation point”: work through 2 doors, man trap).
    • Key readers or biometrics.
    • Physical safe (keep abalog info, hard drive with ROOT_CA).
    • Fire, water, carbon monoxide detectors: protect the human assets.
  • Datacenters:
    • Fire supression system.
    • Heating, ventilaction, AC.
    • Cage lock on racks.
    • Physical intrusion detection lock on computer workstations and servers.
    • Kensington locks on laptops (password-managed locks).
    • Privacy screen filters: keep people from shoulder-surfing.

Browser security

  • Change settings on chromium: Privacy, Search, Services
    • Tracking protection (best intention… keep it balanced, or websites may stop to work).
      • Reputation data.
      • Exception to the rules (e.g. old government websites).
    • Clear browser data (clean the cookies!).
    • Privacy: “do not tracking” (expect best intention from website).
    • Security:
      • Manage certificates.
      • Website typo protection (protects againts “typo squatting”).
      • Secure DNS: usually default by OS.
      • Site premissions restrictions!

Wireless security

  • Access Point:
    • Change default configurations:
      • Change and hide SSID (identifier).
      • Protocols:
        • WEP: weakest, avoid.
        • WPA: weak, avoid.
        • WPA2: strong.
        • WPA3: strongest.
        • WPS: it had best intentions, bad outcome, avoid.
    • Update firmware.
    • Consider using allowlists for critical systems.
    • Consider activating HTTPS.
    • Avoid remote management access (your Internet provider may not allow you to do it).
  • Authentication server (RADIUS, enterprise level).
  • MAC filterting (enterprise level).

Social engineering

Get personal identifying information using deception tactics.

  • Low hanging fruit: people without proper training.
  • Phishing: threat actors:
    • spam: unsolicited emails.
    • phishing: fraudulent emails (not targeted).
    • spear phishing: fraudulent emails (targeted).
    • whaling: fraudulent emails (high-profile employees).
  • Baiting: playing on your necessity (e.g. “usually” too good to be true”,”found a thumbdrive”).
  • Tailgating: someone enters right behind you (not intended).
  • Piggibacking: someone enters right behind you, and you are letting them in (there is an accomplince).
  • Pre-texting: use emotional strings with a story made ahead of time.
  • Shoulder-surfing: looking the screen standing behind the people typing.

OS

AAA: Authentication, Authorization, Accounting.

User Authentication

Proving you are who you say you are.

  • Identity and Access management: credentials + challenge (authentication factors, multifactor authentication).
    • Decentralized (example: C:\Windows\system32\config contains the database registry on SAM file, small workgroups).
    • Centralized (Single Sign-On, Domain environments like Windows Active Directory, on an authority known as Authentication server).
  • Authentication protocols:
    • NTLM: Windows authentication protocol.
    • Kerberos: a centralized time sensitive authentication protocol (Open, MIT, on Windows Active Directory).
    • RADIUS: industry standard for authenticating and authorizing remote users (Open).
    • EAP: authentication framework used commonly on wireless network.

Password Policies

Strings of characters stored in database.

  • Password attacks:
    • Dictionary attack: using a word list.
    • Brute-force: trying every possible combination (more characters = stronger passwords).
    • Rainbow tables: using database of password hashes (most usual passwords, like “123456”).
    • Phishing: email attack using deception.
  • Password policy: fine line between security and usability.
    • Complexity: use all character sets.
    • Length: minimum ammount of characters.
    • Maximum age: maximum duration of a password.
    • History: unique passwords required before password reuse.
  • Account lockout: with time limit, or with administrator contact (secpol.msc in Windows).

Authorization

Once you are authenticated: whar your priviledges over certain resources?

  • Permissions: ACL (Access Control List). They are inherited directory-wise, and can be splitted between local and network permissions (shared permissions).
  • Security principle: review the effective permissions.
    • System: full control.
    • Administrator: full control.
    • Users: read and write.
    • User01: read only.
  • Unix permissions:
    • Read (r).
    • Write (w).
    • Execute (x).

Accounting

What did you do.

Audit Policies

Track events:

  • User activities:
    • Login activities.
    • Accessed resources.
    • Priviledged access.
    • Policy changes.
  • System activities:
    • File access.
    • Priviledged access.
    • Policy changes.
    • Service and dependency changes.

Encryption

graph LR;

A[fa:fa-file Clear text];
B[fa:fa-lock Cypher text];
C[fa:fa-file Clear text];

A -- encryption --> B
B -- decryption --> C

Encryption: cryptographic operation which applies transformation based on keys:

  • Types:
    • Symmetrical key.
      • 🔑 Single key: same key encrypts and decrypts.
      • Faster.
      • Key exchange concerns.
    • Asymmetrical key:
      • 🔑 Public key encrypts.
      • 🔑 Private key decrypts.
      • Slowers.
  • Places where it happens:
    • Software (OS bitlocker).
    • Hardware: dedicated devices.

Certificates

Certificates: file for validating public keys (handled in HTTPS).

  • Utility:
    • Validation (integrity).
    • Public keys (communication).
    • Identification (validate source: users, computers, network devices, software which validates via hash).
  • Types:
    • DER: base 64 encoded (human readable, export only public).
    • PKCS: PKCS#7 (export only public), PKCS#12 (export public+private, like a spare key).

Certificate authorities: issues the certificates, handle validation (not expired, not revoked).

  • Multi-tier structure:
    • ROOTCA: top of trust.
    • Subordinate CAs: endorsed by the root (secondary).
  • Types:
    • Public:
      • Trusted on Internet.
      • Available to buy.
      • Provide PKI.
    • Private:
      • Not publicly trusted.
      • Internal use.
      • Requires infrastructure.

Malware

Umbrella term for malicious software.

  • Types:
    • Virus:
      • Rogue process which corrupts information.
      • Replicates itself.
      • Requires user interaction.
    • Worm:
      • Replicates itself big time.
      • Crawls through network.
      • Hinder performance.
      • Does not require user interaction.
    • Ransomware:
      • Requires user interaction.
      • Encrypts your information, threat actor asks ransom for providing you the private key for recovery.
    • Botnet:
      • Set of remote controlled computers: zombie computers.
      • C2: Command and control
      • Coordinated attack.
    • Rootkit:
      • Infects boot level (Root user UNIX, or Boot-kit on Windows, most priviledge on hardware level, before OS is loaded).
    • Buffer overflow:
      • Memory location gets loaded until it makes information spill out to portions not checked.
      • Hinder performance.
      • Run random code.
    • Torjan horse:
      • Masquearades as benign file.
      • Carrier for other malicious attacks.
    • Backdoor:
      • May be for administrative purposes (e.g. technician handles process).
      • May be used to exploit the system.
    • Spyware:
      • Collect information and sends it to 3rd party.
    • Adware:
      • Pop-ups on Internet.
      • Adblockers help with this.
      • Scareware: subtype of adware: “You are infected” mesage.
    • Zero-day: vulnerability exploitable, that no one knows about it 😭.

Network

Firewalls

Security piece of software, or hardware device (dedicated resources), which acts as barrier between public and private networks. They screen thre traffic “making decisions” (stateless, or more complex with states).

graph LR;

A[fa:fa-laptop Laptop];
C[fa:fa-laptop Laptop];
subgraph Firewall
  B[fa:fa-fire Firewall device]
  D[fa:fa-file File]
  E[fa:fa-certificate Certificate]
end;

A -- inboud traffic --> B;
B -- inboud traffic --> C;
B -- inspection --> D;
D -- checks ACL --> E;
E -- apply action --> B;
E -- default implicit deny --> B;

❗ Check inbound and outbound traffic!

Network Isolation

graph TD;

A((fa:fa-route router));

subgraph BroadcastDomain_A
  B[fa:fa-toggle-on switch]
  D[fa:fa-network-wired VLAN]
  E[fa:fa-network-wired VLAN]
end;

subgraph BroadcastDomain_B
  C[fa:fa-toggle-on switch]
  F[fa:fa-network-wired VLAN]
  G[fa:fa-network-wired VLAN]
end;

A --> B;
A --> C;
B --> D;
B --> E;
C --> F;
C --> G;
  • Communication types:

    • Unit cast: one to one.
    • Broadcast: one to all.
    • Multicast: one to a group (pay-per-view).
  • Routers do not pass broadcast communications between networks: it generates subnets (different solutions may be applied on each one).

    • Broadcast domain: group of computers “within earshot” of broadcast domain.
      • Switch: device that acts as barrier.
        • VLAN: logical separation of computers within switch.
    • NAT (Network Address Translation):
      • Internet: internal IP addresses can not be routed on the Internet by themselves.
graph TD;

A((fa:fa-route router));
G[fa:fa-cloud Internet]

subgraph BroadcastDomain
  B[fa:fa-toggle-on switch]
  C[fa:fa-network-wired VLAN]
  D[fa:fa-network-wired  VLAN]
end;

subgraph Perimeter network
  E[fa:fa-server server published]
  F[fa:fa-server honeypot]
end;

A --> B;
B --> C;
B --> D;

E -- firewalled --> A;
G -- firewalled --> F;
G -- firewalled --> E;
  • Perimeter network (edge network, screened subnet (for remediations, until it complies with policy), DMZ).
  • Honeypots (decoys).
  • Isolation (domain, server).
  • VPN (goes through internel with tunneled encryption, so it gets some internal network priviledges).
graph TD;

A[fa:fa-cloud Internet]
B(fa:fa-phone ISP carrier)
E[fa:fa-phone ISP carrier];

subgraph Company_A
  C((fa:fa-route router))
  D[fa:fa-computerComputer]
end;

subgraph Company_B
  F((fa:fa-route router))
  G[fa:fa-computer Computer]
end;

A --> B;
B --> C;
C --> D;

A --> E;
E --> F;
F --> G;

C -. VPN tunneled encryption .- F;

Secure Protocols

  • Network protocol components:

    • Rules (e.g. best effort).
    • Syntax.
    • Synchronization.
    • Error recovery.
  • Web protocols:

    • HTTP (port 80, insecure).
    • HTTPS (port 443, secure).
  • Remote access control:

    • Telnet (port 23, insecure).
    • SSH (port 22, secure).
    • RDP (port 3389, secure, windows devices).
  • File transfer:

    • FTP (port 21, insecure, usually handled through tunnels).
    • SFTP (port 22, secure).

IPSec

  • Authenticate data origin: protocols can be combined, they are implemented with IPSec policies.

    • Authentication Header (AH): autheticate computers between each other, no encryption.
    • Encapsulating Security Payload (ASP): encrypt communications (confidentiality).
  • Modes:

    • Transport (IP packet encrypted).
    • Tunnel (entire packet encrypted, included payload, used in VPNs).
  • Security associations: 2 for each computer:

    1. Define parameters, encryption types.
    2. Set up encrypted security communication, that’s where we transfer communications over.
  • Package going through tunnel has several fields (track communications):

    1. ID: identifier security association.
    2. Sequence: number, when the information is sent through the tunnel, it can be reconstructed on destination.
    3. Encrypted data.
    4. Checksum: hash, to verify integrity.

Software

Client side

  • Implement authentication.
  • Authorization: principle of least priviledge.
  • User account control: elevated access only when it is required.
  • Use authorized software, with proper certificates.
  • Have network security (antivirus, firewall with implict deny).
  • OS should be updated, with proper encryption.

Email protection

  • Threat:

    • Spam (unsolicited emails).
    • Phishing (malicious emails).
    • Pharming (fraudulent redirect, to grab credentials).
    • Spoofing (malicious emails appearing legitimate).
  • Email server verification:

    • SPF (specify IP addresses of email server for domain).
    • DKIM (email authentication mecanism: the email itself came from the authorized source).
    • DMARC (indicates if SPF and DKIM are implemented).
  • Protect devices mitigation techniques:

    • Email server:
      • Anti-malware software.
      • Basic hardening.
      • Firewall.
      • Spam filters (deny list, having SPF-DKIM-DMARC, content).
    • Email client:
      • Anti-malware software.
      • Antispam.
      • Firewall.
      • Disable macros.
      • Attachments (scan).

Server-side protection

  • Techniques:

    • Access Control (authorized users only).
    • Steer way from defaults (weak or easily discoverable).
    • Principle of least priviledge (limit root or administrative access).
    • Patch management (security updates).
    • Malware protection (real-time protection).
    • Use trusted boot loaders.
  • Security protocols

    Weak Strong
    HTTP HTTPS
    SLL_1, TL_S1.1 TLS_1.2, TLS_1.3
    SMBv1 SMBv3
    SNMPv1 SNMPv3
    Telnet SSH
    FTP SFTP
    DNS (improved?) DNSSEC (certified)

SSH

  • Secure remote connection to another device.
  • Remember to open port 22 on the firewall so it can work (table, TCP).

Enabling

  • On most modern Linux and Unix based operating systems SSH is already enabled by default

    • Is it installed? Look for openssh* (architecture dependant), and openssh-server.

      1
      sudo yum list openssh*
    • Install it.

      1
      2
      3
      4
      5
      sudo yum install openssh-server
      # start in system V
      sudo service sshd start
      # start in systemd
      sudo systemctl start sshd
    • Run it on systen boot.

      1
      sudo chkconfig sshd on
  • Connect (and you will see the certificate, you can save the fingerprint)

    1
    ssh username@123.123.123.123

Using certificates

Autheticating with a certificate instead of a password. Can not be keylogged as it is not typed.

Generate private and public key

Public key is shared, private key is “for us”.

  • Set up on client
    1. Generate certificate, RSA type (in your user profile in there ll be an .ssh hidden folder, with a file id_rsa, you may use a passphrase).
      1
      ssh-keygen -t rsa
    2. Go to .ssh folder: check id_rsa private, id_rsa.pub.
    3. (Optional) send it to a server.
      1
      ssh-copy-id -i /path/to/key.pub SERVERNAME

Set up on server

  • Set up on server (sane as ssh-copy-id)

    1. Check if we have the .ssh folder on userspace.
      1
      2
      3
      ls -la
      # if not found
      mkdir .ssh
    2. Create file for authorized connections
      1
      2
      3
      cd .ssh
      # if not found
      vi /authorized_keys
    3. Type one key per line on the /authorized_keys files.
  • Test it works in the server (using the private key, always do that if you can not access physically to the server to fix it if it goes wrong).

    1
    ssh -i ./id_rsa username@123.123.123.123
  • Disable access via password.

    1. Access the SSH configuration file
      1
      sudo vi /etc/ssh/sshd_config
    2. Find #PubkeyAuthentication, remove the #
    3. Check AuthorizedKeysForFile value, so the file matches.
    4. Check line is PasswordAuthentication, so its value is no.
    5. ChallengeResponseAuthentication should be no
    6. Save and restart the service on the server (sudo systemctl restart shhd).

Connect

  • Even if we reference it, we do not send the private key to the server: we decrypt the answer from the server, which was encoded with the public key, and send the result back. Traffic only moves the public key.
    1
    ssh -i ./id_rsa username@123.123.123.123

Hardening

Check at least is version 2

  1. Go to the server, and check the config file.
    1
    sudo vi /etc/ssh/sshd_configfiles
  2. Look for “the default requires explicit activation of protocol 1” If you see Protocol 1, this is bad (You may also find Protocol 2,1 meaning it accepts both, been tried in that order).

Filer users allowed

  1. Go to the server, and check the config file.
    1
    sudo vi /etc/ssh/sshd_configfiles
  2. Remove root user: look for PermitRootLogin and ensure it is either commented out or set as no.
  3. Review the allowed users list: look for the AllowedUsers and AuthorizedKeyCommands (a list example would be: AllowUsers user1 user2 user3).
  4. Change the port number: look for Port and change it (e.g. Port 9999, and review it is open in your firewall via sudo firewall-cmd --add-port 9999/tcp --permanent).
  5. Restarts the server (systemctl restart sshd).
  6. Connect from client specifying the port (ssh -i ./id_rsa username@123.123.123.123 -p 9999).

Docsify

Definition

  • Docsify generates your documentation website from markdown files on the fly.
  • It does not generate fully static static webpages: it uses online scripts (you can also check docsify-this).

Quick start

  1. Install.

    1
    npm i docsify-cli -g
  2. Initialize (documentation in the ./docs subdirectory).

    1
    docsify init ./docs
  3. Writing content (see the file list in the ./docs subdirectory).

    • index.html: entry file.
    • README.md: home page.
    • .nojekyll: prevents GitHub Pages from ignoring files that begin with an underscore.
  4. Preview your site (on http://localhost:3000).

    1
    docsify serve docs

Index overview

_sidebar.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!-- index.html -->

<!-- optional loading dialog -->
<div id="app">Please wait...</div>
<!-- end of optional loading dialog -->

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta charset="UTF-8" />
<link
rel="stylesheet"
href="//cdn.jsdelivr.net/npm/docsify@4/themes/vue.css"
/>
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
//...
};
</script>
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
</body>
</html>
  • Review version: you can check it on both the script and head link for stylesheet, after the ‘@’ character.

Advanced

Several pages

  • Structure.

    1
    2
    3
    4
    5
    6
    7
    .
    └─ docs
    ├─ README.md
    ├─ guide.md
    └─ es-es
    ├─ README.md
    └─ guide.md
  • Paths.

    1
    2
    3
    4
    docs/README.md        => http://domain.com
    docs/guide.md => http://domain.com/#/guide
    docs/es-es/README.md => http://domain.com/#/es-es/
    docs/es-es/guide.md => http://domain.com/#/es-es/guide
  • Structure.

    1
    2
    3
    4
    5
    └─docs/
    ├─ _sidebar.md
    ├─ index.md
    ├─ getting-started.md
    └─ running-services.md
  • Sidebar file content.

    _sidebar.md
    1
    2
    3
    4
    <!-- docs/_sidebar.md -->

    * [Home](/)
    * [Guide](guide.md)
  • Index requires sidebar configuration to true.

    index.html
    1
    2
    3
    4
    5
    6
    7
    8
    <!-- index.html -->

    <script>
    window.$docsify = {
    loadSidebar: true
    }
    </script>
    <script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
  • Nested sidebars.

    • update after navigation to reflect the current directory by adding a _sidebar.md file to each folder. If the current directory doesn’t have _sidebar.md, it will fall back to the parent directory.

    • update the index file.

      index.html
      1
      2
      3
      4
      5
      6
      7
      8
      <script>
      window.$docsify = {
      loadSidebar: true,
      alias: {
      '/.*/_sidebar.md': '/_sidebar.md'
      }
      }
      </script>
    • Set page titles from sidebar selection to improve SEO.

      _sidebar.md
      1
      2
      3
      <!-- docs/_sidebar.md -->
      * [Home](/)
      * [Guide](guide.md "The greatest guide in the world")

Table of contents

  • Autogeneted by sidebar with subMaxLevel configuration.

    index.html
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <!-- index.html -->

    <script>
    window.$docsify = {
    loadSidebar: true,
    subMaxLevel: 2
    }
    </script>
    <script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
  • Ignoring specific subheaders: add <!-- {docsify-ignore} --> to it.

    1
    2
    3
    4
    # Getting Started

    ## Header <!-- {docsify-ignore} -->
    This header won't appear in the sidebar table of contents.
  • Ignore all headers: <!-- {docsify-ignore-all} --> on the first header of the page.

    1
    2
    3
    4
    # Getting Started <!-- {docsify-ignore-all} -->

    ## Header
    This header won't appear in the sidebar table of contents.

Custom navbar

  • HTML only: doc links begin with #.

    index.html
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <!-- index.html -->

    <body>
    <nav>
    <a href="#/">EN</a>
    <a href="#/es-es/">ES></a>
    </nav>
    <div id="app"></div>
    </body>
  • Markdown alternative: you can create a custom markdown-based navigation file by setting loadNavbar to true and creating _navbar.md

    index.html
    1
    2
    3
    4
    5
    6
    7
    8
    <!-- index.html -->

    <script>
    window.$docsify = {
    loadNavbar: true
    }
    </script>
    <script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
    _navbar.md
    1
    2
    3
    4
    <!-- _navbar.md -->

    * [En](/)
    * [Es](/es-es/)
  • Nesting.

    _navbar.md
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    <!-- _navbar.md -->

    * Getting started

    * [Quick start](quickstart.md)
    * [Writing more pages](more-pages.md)
    * [Custom navbar](custom-navbar.md)
    * [Cover page](cover.md)

    * Configuration
    * [Configuration](configuration.md)
    * [Themes](themes.md)
    * [Using plugins](plugins.md)
    * [Markdown configuration](markdown.md)
    * [Language highlight](language-highlight.md)

Cover page

  • Basics.

    index.html
    1
    2
    3
    4
    5
    6
    7
    8
    <!-- index.html -->

    <script>
    window.$docsify = {
    coverpage: true
    }
    </script>
    <script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
    _coverpage.md
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    <!-- _coverpage.md -->

    ![logo](_media/icon.svg)

    # docsify <small>3.5</small>

    > A magical documentation site generator.

    - Simple and lightweight
    - No statically built html files
    - Multiple themes

    [GitHub](https://github.com/docsifyjs/docsify/)
    [Get Started](#docsify)
  • Custom background.

    _coverpage.md
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    <!-- _coverpage.md -->

    # docsify <small>3.5</small>

    [GitHub](https://github.com/docsifyjs/docsify/)
    [Get Started](#quick-start)

    <!-- background image -->

    ![](_media/bg.png)

    <!-- background color -->

    ![color](#f0f0f0)
  • Multiple coverpages by level.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    .
    └─docs
    ├─ README.md
    ├─ guide.md
    ├─ _coverpage.md
    └─ es-es
    ├─ README.md
    └─ guide.md
    └─ _coverpage.md
    • general.

      index.html
      1
      2
      3
      window.$docsify = {
      coverpage: ['/', '/es-es/']
      };
    • special filename.

      index.html
      1
      2
      3
      4
      5
      6
      window.$docsify = {
      coverpage: {
      '/': 'cover.md',
      '/es-es/': 'cover.md'
      }
      };

Themes

See Themeable.

1
2
3
4
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/vue.css" />
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/buble.css" />
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/dark.css" />
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/pure.css" />

Plugins

Using localstorage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<script>
window.$docsify = {
search: 'auto', // default

search: [
'/', // => /README.md
'/guide', // => /guide.md
'/get-started', // => /get-started.md
'/es-es/', // => /es-es/README.md
],

// complete configuration parameters
search: {
maxAge: 86400000, // Expiration time, the default one day
paths: [], // or 'auto'
placeholder: 'Type to search',

// Localization
placeholder: {
'/es-es/': 'ES',
'/': 'Type to search',
},

noData: 'No Results!',

// Localization
noData: {
'/es-es/': 'ES',
'/': 'Sin resultados',
},

// Headline depth, 1 - 6
depth: 2,

hideOtherSidebarContent: false, // whether or not to hide other sidebar content

// To avoid search index collision
// between multiple websites under the same domain
namespace: 'website-1',

// Use different indexes for path prefixes (namespaces).
// NOTE: Only works in 'auto' mode.
//
// When initialiazing an index, we look for the first path from the sidebar.
// If it matches the prefix from the list, we switch to the corresponding index.
pathNamespaces: ['/es-es', '/zh-cn', '/zh-cn/v1'],

// You can provide a regexp to match prefixes. In this case,
// the matching substring will be used to identify the index
pathNamespaces: /^(\/(es-es|zh-cn))?(\/(v1|v2))?/,
},
};
</script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script>

Emoji

1
2
3
4
5
6
7
8
9
<!-- index.html -->

<script>
window.$docsify = {
// ...
}
</script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/emoji.min.js"></script>
1
2
3
4
<!-- _navbar.md -->

* [:us:, :uk:](/)
* [:es:](/es-es/)

Copy to clipboard

1
<script src="//cdn.jsdelivr.net/npm/docsify-copy-code/dist/docsify-copy-code.min.js"></script>

Requirements

Rembg requires at least Python 3.7

Install

1
2
3
# work on virtual environment is recommended
python -m venv /home/don/PythonCoding
python -m pip install rembg

Remove background

First time it is run, it downloads a pattern recognition model.

1
rembg i d_original.jpg d_noback.jpg

Flags

  • rembg i: image files.
  • rembg p: image folders.
  • rembg s: images HTTP server.

check-ecs-exec.sh checks and validates both your CLI environment and ECS cluster/task are ready for ECS Exec, by calling various AWS APIs on behalf of you.

Prerequisites

  • jq
  • AWS CLI v1.19.28/v2.1.30 or later
  • IAM role permissions:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    {
    "Version": "2012-10-17",
    "Statement": [
    {
    "Effect": "Allow",
    "Action": [
    "iam:ListRoles",
    "iam:GetInstanceProfile",
    "iam:SimulatePrincipalPolicy",
    "kms:DescribeKey",
    "ec2:DescribeSubnets",
    "ec2:DescribeVpcEndpoints",
    "ecs:DescribeClusters",
    "ecs:DescribeContainerInstances",
    "ecs:DescribeTaskDefinition",
    "ecs:DescribeTasks"
    ],
    "Resource": "*"
    }
    ]
    }

Usage

Basic

1
./check-ecs-exec.sh <YOUR_ECS_CLUSTER_NAME> <YOUR_ECS_TASK_ID>

Run without cloning Git repo

It will use your default AWS CLI profile and the AWS region.

1
2
bash <( curl -Ls https://raw.githubusercontent.com/aws-containers/amazon-ecs-exec-checker/main/check-ecs-exec.sh ) \ 
<YOUR_ECS_CLUSTER_NAME> <YOUR_ECS_TASK_ID>

Run with AWS_* variables

1
2
3
4
export AWS_PROFILE=myprofile
export AWS_REGION=eu-west-1

bash ./check-ecs-exec.sh <YOUR_ECS_CLUSTER_NAME> <YOUR_ECS_TASK_ID>

Run with MFA

  • It autodetects your MFA configuration for the AWS CLI.
    1
    2
    3
    4
    5
    6
    [profile profile-one]
    role_arn = arn:aws:iam::123456789012:role/cool-role
    mfa_serial = arn:aws:iam::123456789012:mfa/user_name
    source_profile = iam
    region = eu-west-1
    output = json
  • You can also use the AWS_MFA_SERIAL environment variable.

Switch AWS CLI binaries

1
AWS_CLI_BIN=aws-v1 ./check-ecs-exec.sh <YOUR_ECS_CLUSTER_NAME> <YOUR_ECS_TASK_ID>

Checks

  • 🟢 (Green) - The configuration or the status is okay.
  • 🟡 (Yellow) - The configuration or the status should or would be recommended to fix, but you can use ECS Exec without fixing them.
  • 🔴 (Red) - You need to fix those results before using ECS Exec.

FAQ

Pre-flight

  • 🔴 Pre-flight check failed: jq command is missing: install the jq command.
  • 🔴 Pre-flight check failed: aws command is missing: install the latest AWS CLI.
  • 🔴 Pre-flight check failed: ECS Exec requires the AWS CLI v1.19.28/v2.1.30 or later: upgrade AWS CLI.

Configuration

Command execution

  • 🔴 Can I ExecuteCommand? | ecs:ExecuteCommand: implicitDeny: you need ecs:ExecuteCommand. Note: the Condition element of the IAM policy is not currently supported to evaluate by check-ecs-exec.sh.
  • 🔴 Can I ExecuteCommand? | kms:GenerateDataKey: implicitDeny: You need kms:GenerateDataKey, with the given KMS Key ID which you’re using for the logging and auditing configuration for ECS exec.
  • 🟡 Can I ExecuteCommand? | ssm:StartSession denied?: allowed: You need ssm:StartSession. Recomendation, not blocker.

Task status

  • 🔴 Task Status | DEACTIVATING or STOPPING or DEPROVISIONING or STOPPED: the ECS task has already stopped, or is shutting down. Restart it, check Task lifecycle.
  • 🟡 Task Status | PROVISIONING or ACTIVATING or PENDING:the ECS task is in the middle of its starting process. Wait few more seconds for the task to be ready.

Version issues

  • 🔴 Platform Version | 1.3.0 (Required: >= 1.4.0): On AWS Fargate, ECS Exec requires the Platform version 1.4.0 or higher (Linux) or 1.0.0 (Windows).
    • ECS service case: update the platform version by specifying the PlatformVersion parameter for the UpdateService API.
    • Standalone task case: re-run the ECS task with the PlatformVersion parameter specified for the RunTask API.
  • 🔴 ECS Agent Version | x.y.z (Required: >= 1.50.2): update the version of the ECS Container Agent for your EC2 instance where your ECS task runs.

Resource issues

  • 🔴 Exec Enabled for Task | NO: enable the ECS Exec feature.
    • ECS service case: update the ECS by specifying the EnableExecuteCommand parameter for the UpdateService API.
    • Standalone task case: re-run the ECS task with the EnableExecuteCommand parameter specified for the RunTask API.
  • 🔴 Managed Agent Status | STOPPED (Reason: stopped-reason-here): The managed agent for a container in your Task has stopped for reasons related to other existing problems. Clearing other errors detected and rerun.
  • 🟡 Init Process Enabled | Disabled: Recommended, not blocker. Add the initProcessEnabled flag to your ECS task definition for each container to avoid having orphaned and zombie processes.
  • 🔴 Read-Only Root Filesystem | ReadOnly: the SSM agent requires that the container file system is able to be written in order to create the required directories and files.You need to set the readonlyRootFilesystem flag as false in your task definition.
  • 🔴 EC2 or Task Role | Not Configured” or {serviceName}:{ActionName}: implicitDeny: it needs a task role or an instance role of the underlying EC2 instance with some permissions for using SSM Session Manager at least. Note: that the Condition element of the IAM policy is not currently supported.
  • 🟡 SSM PrivateLink “com.amazonaws.(region).ssmmessages” not found: there are VPC endpoints configured in the VPC for your task, so you may want to add an additional SSM PrivateLink for your VPC.
  • 🔴 VPC Endpoints | CHECK FAILED: check-ecs-exec.sh doesn’t support checking this item for shared VPC subnets using AWS Resouce Access Manager (AWS RAM). In short, this may not an issue to use ECS Exec if your ECS task VPC doesn’t have any VPC endpoint and the task has proper outbound internet connectivity. Make sure to consult your administrator with the official ECS Exec documentation to find if your VPC need to have an additional VPC endpoint.
  • 🟡 Environment Variables : defined: SSM uses the AWS SDK, which uses the default chain when determining authentication.If AWS_ACCESS_KEY, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY are defined in the environment variables and the permissions there do not provide the required permissions for SSM to work, then the execute-command will fail. It is recomended not to define these environment variables.
0%