Day 08
Topics to cover
01 Gitalab Installation
02 Curl
03 Openssl
π Introduction to GitLab
GitLab is a web-based DevOps lifecycle tool that provides a Git repository manager with built-in features like:
- Issue tracking
- Continuous Integration/Continuous Deployment (CI/CD)
- Code review
- Project management
- Wiki and more
It enables teams to collaborate on code, automate testing, and deploy software efficiently.
π§ What Is Git?
Before diving into GitLab, it’s important to understand Git:
- Git is a version control system that lets you track code changes.
- It allows multiple developers to work on the same project simultaneously.
GitLab builds on Git by providing a collaborative platform for managing and deploying code.
π GitLab vs GitHub vs Bitbucket
| Feature | GitLab | GitHub | Bitbucket |
|---|---|---|---|
| CI/CD Built-in | β Yes | β οΈ Needs Actions | β Yes |
| Self-hosted | β Available | β Enterprise | β Available |
| Open Source | β Core version | β | β |
π Key Features of GitLab
- Repositories: Git-based version control for code.
- CI/CD Pipelines: Automate building, testing, and deploying your code.
- Merge Requests: Review and approve code changes.
- Issue Tracking: Built-in project management tools.
- Security & Compliance: SAST, DAST, container scanning, etc.
- Wiki & Docs: Project documentation support.
π οΈ GitLab Editions
- GitLab SaaS: Hosted on GitLab.com
- GitLab Self-Managed: You install and run GitLab on your own server
Versions:
- Free β Core features
- Premium β Enhanced CI/CD and support
- Ultimate β Security, compliance, and performance features
π¦ Basic GitLab Workflow
Clone the Repository
git clone https://gitlab.com/username/project.gitCreate a Branch
git checkout -b feature-branchMake Changes and Commit
git add . git commit -m "Added new feature"Push to GitLab
git push origin feature-branchCreate a Merge Request (MR) via the GitLab UI
Code Review and Merge into the main branch
π CI/CD Pipeline Example
.gitlab-ci.yml file defines your pipeline:
stages:
- build
- test
- deploy
build-job:
stage: build
script:
- echo "Building the app..."
test-job:
stage: test
script:
- echo "Running tests..."
deploy-job:
stage: deploy
script:
- echo "Deploying the app..."β Why Use GitLab?
- All-in-one DevOps platform
- Improves collaboration and code quality
- Automates the software delivery lifecycle
- Scalable for both small teams and large enterprises
π Learn More
- Official site: https://about.gitlab.com
- Docs: https://docs.gitlab.com
- GitLab CI/CD: https://docs.gitlab.com/ee/ci
GitLab helps you code, collaborate, and deploy β all in one place. π»π
Gitlab Installation
- Create a Linux vm with 8GB of RAM , 2CPU min and 50GB of Disk space
- Have one public Domain
- Follow the steps given here
π Most Common curl Commands
curl is a command-line tool used for transferring data to or from a server using various protocols such as HTTP, HTTPS, FTP, and more.
π 1. Test Connectivity (Like telnet for HTTP)
To check if a service is reachable and responding on a specific port:
curl -v telnet://hostname:portExample:
curl -v telnet://example.com:80Works similar to
telnet, but only for protocolscurlsupports.
π₯ 2. Download a File (Like wget)
curl -O https://example.com/file.tar.gz-O: Saves the file with its original name.
Download and rename:
curl -o newname.tar.gz https://example.com/file.tar.gzπ€ 3. Upload a File (Using POST)
curl -F "file=@/path/to/file.txt" https://example.com/uploadUsed for uploading files via web forms.
π 4. Make a POST Request
curl -X POST -d "username=user&password=pass" https://example.com/loginOr with JSON:
curl -X POST -H "Content-Type: application/json" \
-d '{"username":"user", "password":"pass"}' \
https://example.com/api/loginπ 5. View HTTP Headers Only
curl -I https://example.comShows only the response headers (
HEADrequest).
π§ͺ 6. Check HTTP Status Code
curl -o /dev/null -s -w "%{http_code}\n" https://example.comOnly prints the HTTP response code like
200,404, etc.
πͺͺ 7. Send Custom Headers (e.g. API Tokens)
curl -H "Authorization: Bearer <token>" https://api.example.com/dataπ§° 8. Debug Full Request/Response
curl -v https://example.comUse
-v(verbose) or--tracefor full request/response logs.
π 9. Follow Redirects
curl -L https://short.url/linkFollows HTTP 3xx redirects (like a shortened URL).
π‘ 10. Download from FTP Server
curl -u username:password ftp://ftp.example.com/file.zip -Oπ‘ Tips
- Add
-kto ignore SSL certificate validation (not recommended for production):curl -k https://example.com - Add
-sfor silent mode (no progress bar or errors). - Use
-u user:passfor basic auth.
π Learn More
- Official Docs: https://curl.se/docs/
- Protocols Supported: HTTP, HTTPS, FTP, SFTP, SCP, LDAP, and more
curl is like a Swiss Army knife for HTTP and beyond β learn it once, use it everywhere. π§π
Openssl Commands
- 1οΈβ£ Generate a Self-Signed Certificate: Create a self-signed SSL certificate with a private key
openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout server.key -out server.crt- 2οΈβ£ Generate a Private Key: Generate a private RSA key
openssl genpkey -algorithm RSA -out private.key- 3οΈβ£ Generate a Public Key: Generate a public key from a private key
openssl rsa -in private.key -pubout -out public.key- 4οΈβ£ Convert PEM to DER: Convert a PEM-encoded certificate to DER format
openssl x509 -in certificate.pem -outform DER -out certificate.der- 5οΈβ£ Convert DER to PEM: Convert a DER-encoded certificate to PEM format
openssl x509 -in certificate.der -inform DER -out certificate.pem -outform PEM- 6οΈβ£ View Certificate Information: View details about an SSL certificate
openssl x509 -in certificate.crt -text -noout- 7οΈβ£ Verify Certificate: Verify if a certificate is valid for a specific domain
openssl s_client -connect example.com:443 -showcerts- 8οΈβ£ Create a CSR (Certificate Signing Request): Generate a CSR using a private key
openssl req -new -key private.key -out request.csr- 9οΈβ£ Sign a CSR with a CA (Certificate Authority): Sign a CSR with a CA certificate
openssl x509 -req -in request.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out signed.crt -days 365- π Check SSL Certificate Expiry: Check the expiration date of an SSL certificate
openssl x509 -in certificate.crt -noout -enddate- 1οΈβ£1οΈβ£ Create a PKCS12 File: Convert a private key and certificate to a PKCS12 file
openssl pkcs12 -export -in certificate.crt -inkey private.key -out certificate.p12- 1οΈβ£2οΈβ£ Extract Certificate from PKCS12 File: Extract a certificate from a PKCS12 file
openssl pkcs12 -in certificate.p12 -clcerts -nokeys -out certificate.crt- 1οΈβ£3οΈβ£ Extract Private Key from PKCS12 File: Extract the private key from a PKCS12 file
openssl pkcs12 -in certificate.p12 -nocerts -out private.key- 1οΈβ£4οΈβ£ Encrypt a File with AES: Encrypt a file using AES encryption
openssl enc -aes-256-cbc -salt -in plaintext.txt -out encrypted.txt- 1οΈβ£5οΈβ£ Decrypt a File with AES: Decrypt a file that was encrypted with AES
openssl enc -d -aes-256-cbc -in encrypted.txt -out decrypted.txt- 1οΈβ£6οΈβ£ Generate a Diffie-Hellman Parameters File: Generate a DH parameters file
openssl dhparam -out dhparams.pem 2048- 1οΈβ£7οΈβ£ Create an SSL/TLS Server Certificate: Generate a server certificate from a CSR
openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 365- 1οΈβ£8οΈβ£ Test SSL Connection: Test an SSL connection to a server
openssl s_client -connect example.com:443- 1οΈβ£9οΈβ£ Generate an MD5 Hash of a File: Generate an MD5 hash of a file
openssl dgst -md5 file.txt- 2οΈβ£0οΈβ£ Generate a SHA256 Hash of a File: Generate a SHA256 hash of a file
openssl dgst -sha256 file.txt- 1οΈβ£ Generate a Self-Signed Certificate: Create a self-signed SSL certificate with a private key
openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout server.key -out server.crt- 2οΈβ£ Generate a Private Key: Generate a private RSA key
openssl genpkey -algorithm RSA -out private.key- 3οΈβ£ Generate a Public Key: Generate a public key from a private key
openssl rsa -in private.key -pubout -out public.key- 4οΈβ£ Convert PEM to DER: Convert a PEM-encoded certificate to DER format
openssl x509 -in certificate.pem -outform DER -out certificate.der- 5οΈβ£ Convert DER to PEM: Convert a DER-encoded certificate to PEM format
openssl x509 -in certificate.der -inform DER -out certificate.pem -outform PEM- 6οΈβ£ View Certificate Information: View details about an SSL certificate
openssl x509 -in certificate.crt -text -noout- 7οΈβ£ Verify Certificate: Verify if a certificate is valid for a specific domain
openssl s_client -connect example.com:443 -showcerts- 8οΈβ£ Create a CSR (Certificate Signing Request): Generate a CSR using a private key
openssl req -new -key private.key -out request.csr- 9οΈβ£ Sign a CSR with a CA (Certificate Authority): Sign a CSR with a CA certificate
openssl x509 -req -in request.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out signed.crt -days 365- π Check SSL Certificate Expiry: Check the expiration date of an SSL certificate
openssl x509 -in certificate.crt -noout -enddate- 1οΈβ£1οΈβ£ Create a PKCS12 File: Convert a private key and certificate to a PKCS12 file
openssl pkcs12 -export -in certificate.crt -inkey private.key -out certificate.p12- 1οΈβ£2οΈβ£ Extract Certificate from PKCS12 File: Extract a certificate from a PKCS12 file
openssl pkcs12 -in certificate.p12 -clcerts -nokeys -out certificate.crt- 1οΈβ£3οΈβ£ Extract Private Key from PKCS12 File: Extract the private key from a PKCS12 file
openssl pkcs12 -in certificate.p12 -nocerts -out private.key- 1οΈβ£4οΈβ£ Encrypt a File with AES: Encrypt a file using AES encryption
openssl enc -aes-256-cbc -salt -in plaintext.txt -out encrypted.txt- 1οΈβ£5οΈβ£ Decrypt a File with AES: Decrypt a file that was encrypted with AES
openssl enc -d -aes-256-cbc -in encrypted.txt -out decrypted.txt- 1οΈβ£6οΈβ£ Generate a Diffie-Hellman Parameters File: Generate a DH parameters file
openssl dhparam -out dhparams.pem 2048- 1οΈβ£7οΈβ£ Create an SSL/TLS Server Certificate: Generate a server certificate from a CSR
openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 365- 1οΈβ£8οΈβ£ Test SSL Connection: Test an SSL connection to a server
openssl s_client -connect example.com:443- 1οΈβ£9οΈβ£ Generate an MD5 Hash of a File: Generate an MD5 hash of a file
openssl dgst -md5 file.txt- 2οΈβ£0οΈβ£ Generate a SHA256 Hash of a File: Generate a SHA256 hash of a file
openssl dgst -sha256 file.txt