├── 0x0B-ssh ├── README.md ├── 2-ssh_config ├── 1-create_ssh_key_pair ├── 0-use_a_private_key └── 100-puppet_ssh_config.pp ├── 0x15-api ├── README.md ├── 0-gather_data_from_an_API.py ├── 1-export_to_CSV.py ├── 3-dictionary_of_list_of_dictionaries.py └── 2-export_to_JSON.py ├── 0x00-shell_basics ├── README.md ├── 1-listit ├── 10-back ├── 2-bring_me_home ├── 3-listfiles ├── 4-listmorefiles ├── 11-lists ├── 14-copy_html ├── 5-listfilesdigitonly ├── 0-current_working_directory ├── 12-file_type ├── 13-symbolic_link ├── 6-firstdirectory ├── 8-firstdelete ├── 9-firstdirdeletion ├── 7-movethatfile └── .0-current_working_directory.swp ├── 0x0C-web_server ├── README.md ├── 2-setup_a_domain_name ├── 1-install_nginx_web_server ├── 3-redirection ├── 0-transfer_file ├── 4-not_found_page_404 └── 7-puppet_install_nginx_web_server.pp ├── 0x10-https_ssl ├── README.md ├── 0-world_wide_web ├── 1-haproxy_ssl_termination └── 100-redirect_http_to_https ├── 0x07-networking_basics ├── 0-OSI_model ├── 2-MAC_and_IP_address ├── 3-UDP_and_TCP ├── 1-types_of_network ├── 4-TCP_and_UDP_ports ├── 5-is_the_host_on_the_network └── README.md ├── 0x0F-load_balancer ├── README.md ├── 2-puppet_custom_http_response_header.pp ├── 1-install_load_balancer └── 0-custom_http_response_header ├── 0x02-shell_redirections ├── README.md ├── 21-reverse ├── 20-hiago ├── 13-unique ├── 12-newest_files ├── 19-AZ ├── 2-hellofile ├── 0-hello_world ├── 1-confused_smiley ├── 4-lastlines ├── 102-acrostic ├── 3-twofiles ├── 5-firstlines ├── 8-cwd_state ├── 14-findthatword ├── 16-whatsnext ├── 17-hidethisword ├── 6-third_line ├── 10-no_more_js ├── 15-countthatword ├── 9-duplicate_last_line ├── 11-directories ├── 18-letteronly ├── 22-users_and_homes ├── 100-empty_casks ├── 7-file ├── 101-gifs └── 103-the_biggest_fan ├── 0x01-shell_permissions ├── 2-groups ├── 0-iam_betty ├── 1-who_am_i ├── 4-empty ├── README.md ├── 3-new_owner ├── 5-execute ├── 7-everybody ├── 8-James_Bond ├── 9-John_Doe ├── 13-change_group ├── 11-directories_permissions ├── 12-directory_permissions ├── 6-multiple_permissions └── 10-mirror_permissions ├── 0x06-regular_expressions ├── README.md ├── 0-simply_match_school.rb ├── 2-repetition_token_1.rb ├── 3-repetition_token_2.rb ├── 4-repetition_token_3.rb ├── 5-beginning_and_end.rb ├── 6-phone_number.rb ├── 1-repetition_token_0.rb ├── 7-OMG_WHY_ARE_YOU_SHOUTING.rb └── 100-textme.rb ├── 0x0D-web_stack_debugging_0 ├── README.md └── 0-give_me_a_page ├── 0x0A-configuration_management ├── README.md ├── killmenow ├── 2-execute_a_command.pp ├── 0-create_a_file.pp └── 1-install_a_package.pp ├── 0x0E-web_stack_debugging_1 ├── README.md ├── 1-debugging_made_short └── 0-nginx_likes_port_80 ├── 0x03-shell_variables_expansions ├── 5-local_variables ├── 0-alias ├── README.md ├── 1-hello_you ├── 4-global_variables ├── 101-rot13 ├── 2-path ├── 102-odd ├── 13-print_float ├── 6-create_local_variable ├── 11-binary_to_decimal ├── 7-create_global_variable ├── 9-divide_and_rule ├── 10-love_exponent_breath ├── 100-decimal_to_hexadecimal ├── 3-paths ├── 8-true_knowledge ├── 12-combinations └── 103-water_and_stir ├── 0x04-loops_conditions_and_parsing ├── README.md ├── 1-for_best_school ├── 102-lets_parse_apache_logs ├── 2-while_best_school ├── 3-until_best_school ├── 8-for_ls ├── 100-read_and_cut ├── 4-if_9_say_hi ├── 103-dig_the-data ├── 7-clock ├── 101-tell_the_story_of_passwd ├── 9-to_file_or_not_to_file ├── 5-4_bad_luck_8_is_your_chance ├── 6-superstitious_numbers ├── 0-RSA_public_key.pub └── 10-fizzbuzz ├── 0x08-networking_basics_2 ├── 100-port_listening_on_localhost ├── 1-show_attached_IPs ├── 0-change_your_home_IP └── README.md ├── 0x09-web_infrastructure_design ├── 0-simple_web_stack.png ├── 1-distributed_web_infrastructure.png ├── 2-secured_and_monitored_web_infrastructure.png ├── 0-simple_web_stack.md ├── 1-distributed_web_infrastructure.md └── 2-secured_and_monitored_web_infrastructure.md └── 0x13-firewall ├── 0-block_all_incoming_traffic_but ├── README.md └── 100-port_forwarding /0x0B-ssh/README.md: -------------------------------------------------------------------------------- 1 | # 0x0B-ssh -------------------------------------------------------------------------------- /0x15-api/README.md: -------------------------------------------------------------------------------- 1 | # 0x15-API -------------------------------------------------------------------------------- /0x00-shell_basics/README.md: -------------------------------------------------------------------------------- 1 | Hello world 2 | -------------------------------------------------------------------------------- /0x0C-web_server/README.md: -------------------------------------------------------------------------------- 1 | 0x0C-web_server -------------------------------------------------------------------------------- /0x10-https_ssl/README.md: -------------------------------------------------------------------------------- 1 | # 0x10-https_ssl -------------------------------------------------------------------------------- /0x07-networking_basics/0-OSI_model: -------------------------------------------------------------------------------- 1 | 2 2 | 2 3 | -------------------------------------------------------------------------------- /0x0C-web_server/2-setup_a_domain_name: -------------------------------------------------------------------------------- 1 | ragab.tech -------------------------------------------------------------------------------- /0x0F-load_balancer/README.md: -------------------------------------------------------------------------------- 1 | # 0x0F-load_balancer -------------------------------------------------------------------------------- /0x00-shell_basics/1-listit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/10-back: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd - 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/README.md: -------------------------------------------------------------------------------- 1 | Hello World 2 | -------------------------------------------------------------------------------- /0x00-shell_basics/2-bring_me_home: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/3-listfiles: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -l 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/2-groups: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | groups 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/21-reverse: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rev 3 | -------------------------------------------------------------------------------- /0x07-networking_basics/2-MAC_and_IP_address: -------------------------------------------------------------------------------- 1 | 2 2 | 1 3 | -------------------------------------------------------------------------------- /0x07-networking_basics/3-UDP_and_TCP: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 1 4 | -------------------------------------------------------------------------------- /0x00-shell_basics/4-listmorefiles: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -a -l 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/0-iam_betty: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | su betty 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/1-who_am_i: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | whoami 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/4-empty: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | touch hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/README.md: -------------------------------------------------------------------------------- 1 | #0x01-shell_permissions 2 | -------------------------------------------------------------------------------- /0x02-shell_redirections/20-hiago: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tr -d "Cc" 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/README.md: -------------------------------------------------------------------------------- 1 | # 0x06-regular_expressions -------------------------------------------------------------------------------- /0x07-networking_basics/1-types_of_network: -------------------------------------------------------------------------------- 1 | 3 2 | 2 3 | 1 4 | -------------------------------------------------------------------------------- /0x0D-web_stack_debugging_0/README.md: -------------------------------------------------------------------------------- 1 | 0x0D-web_stack_debugging_0 -------------------------------------------------------------------------------- /0x00-shell_basics/11-lists: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -la . .. /boot 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/14-copy_html: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cp -u *.html .. 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/5-listfilesdigitonly: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -na 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/13-unique: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sort | uniq -u 3 | -------------------------------------------------------------------------------- /0x0A-configuration_management/README.md: -------------------------------------------------------------------------------- 1 | 0x0A-configuration_management -------------------------------------------------------------------------------- /0x0E-web_stack_debugging_1/README.md: -------------------------------------------------------------------------------- 1 | # 0x0E-web_stack_debugging_1 -------------------------------------------------------------------------------- /0x00-shell_basics/0-current_working_directory: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | pwd 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/12-file_type: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | file /tmp/iamafile 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/3-new_owner: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chown betty hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/5-execute: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod u+x,o+r hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/7-everybody: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod a+x hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/8-James_Bond: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod 007 hello 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/9-John_Doe: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod 753 hello 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/12-newest_files: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -t1 | head 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/19-AZ: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tr "A" "Z" | tr "c" "e" 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/2-hellofile: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cat /etc/passwd 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/5-local_variables: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/13-symbolic_link: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ln -s /bin/ls __ls__ 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/13-change_group: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chgrp school hello 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/0-hello_world: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Hello, World" 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/1-confused_smiley: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "\"(Ôo)'" 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/4-lastlines: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tail -n 10 /etc/passwd 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/0-alias: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | alias ls="rm *" 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/README.md: -------------------------------------------------------------------------------- 1 | 0x03-shell_variables_expansions 2 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/README.md: -------------------------------------------------------------------------------- 1 | # Loops, conditions and parsing -------------------------------------------------------------------------------- /0x02-shell_redirections/102-acrostic: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cut -c 1 | paste -s -d '' 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/3-twofiles: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cat /etc/passwd /etc/hosts 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/5-firstlines: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | head -n 10 /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/8-cwd_state: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ls -la > ls_cwd_content 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/1-hello_you: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "hello $USER" 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/4-global_variables: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | printenv 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/6-firstdirectory: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir /tmp/my_first_directory/ 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/8-firstdelete: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm /tmp/my_first_directory/betty 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/9-firstdirdeletion: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -r /tmp/my_first_directory 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/11-directories_permissions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod -R a+X . 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/12-directory_permissions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -m 751 my_dir 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/14-findthatword: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -i "root" /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/16-whatsnext: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -i "root" -A 3 /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/17-hidethisword: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -i -v "bin" /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/6-third_line: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | head -n 3 iacta | tail -n 1 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/101-rot13: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tr 'A-Za-z' 'N-ZA-Mn-za-m' 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/2-path: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export PATH=$PATH:/action 3 | -------------------------------------------------------------------------------- /0x00-shell_basics/7-movethatfile: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mv /tmp/betty /tmp/my_first_directory 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/6-multiple_permissions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod u+x,g+x,o+r hello 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/10-no_more_js: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -type f -name "*.js" -delete 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/15-countthatword: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -c -i "bin" /etc/passwd 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/9-duplicate_last_line: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tail -n 1 iacta >> iacta 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/102-odd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | perl -lne 'print if $. % 2 ==1' 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/13-print_float: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | printf "%.2f" $NUM | sort 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/6-create_local_variable: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | BEST="School" 3 | -------------------------------------------------------------------------------- /0x01-shell_permissions/10-mirror_permissions: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | chmod --reference=olleh hello 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/11-directories: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -type d -not -name '.' | wc -l 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/18-letteronly: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | grep -i "^[a-z]" /etc/ssh/sshd_config 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/22-users_and_homes: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cut -d ":" -f1,6 /etc/passwd | sort 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/11-binary_to_decimal: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "$((2#$BINARY))" 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/7-create_global_variable: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export BEST=School 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/9-divide_and_rule: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo $(($POWER / $DIVIDE)) 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/10-love_exponent_breath: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo $((BREATH**$LOVE)) 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/100-decimal_to_hexadecimal: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | printf '%x\n' $DECIMAL 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/100-empty_casks: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find . -empty | rev | cut -d '/' -f 1 | rev 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/3-paths: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo $((`echo $PATH | grep -o ":/" | wc -l`+ 1)) 3 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/8-true_knowledge: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo $(($TRUEKNOWLEDGE + 128)) 3 | 4 | -------------------------------------------------------------------------------- /0x06-regular_expressions/0-simply_match_school.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/School/).join -------------------------------------------------------------------------------- /0x06-regular_expressions/2-repetition_token_1.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/hb*tn/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/3-repetition_token_2.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/hbt+n/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/4-repetition_token_3.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/hbt*n/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/5-beginning_and_end.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/^h.n$/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/6-phone_number.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/^\d{10,10}$/).join 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/1-repetition_token_0.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/hbt{2,5}n/).join 3 | -------------------------------------------------------------------------------- /0x0A-configuration_management/killmenow: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | while [[ true ]] 3 | do 4 | sleep 2 5 | done 6 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/12-combinations: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo {a..z}{a..z} | tr " " "\n" | grep -v "oo" 3 | -------------------------------------------------------------------------------- /0x06-regular_expressions/7-OMG_WHY_ARE_YOU_SHOUTING.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/[A-Z]*/).join 3 | -------------------------------------------------------------------------------- /0x0B-ssh/2-ssh_config: -------------------------------------------------------------------------------- 1 | # ssh config file 2 | Host * 3 | PasswordAuthentication no 4 | IdentifyFile ~/.ssh/school -------------------------------------------------------------------------------- /0x02-shell_redirections/7-file: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Best School" > \\*\\\\\'\""Best School"\"\\\'\\\\*$\\?\\*\\*\\*\\*\\*:\) 3 | -------------------------------------------------------------------------------- /0x0B-ssh/1-create_ssh_key_pair: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Creates RSA key pair 3 | 4 | ssh-keygen -b 4096 -f school -t rsa -N betty -------------------------------------------------------------------------------- /0x06-regular_expressions/100-textme.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts ARGV[0].scan(/\[from:(.*?)\] \[to:(.*?)\] \[flags:(.*?)\]/).join(",") 3 | -------------------------------------------------------------------------------- /0x02-shell_redirections/101-gifs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | find -name '*.gif' -type f | rev | cut -d "/" -f 1 | cut -d "." 2- | rev | LC_ALL=C sort -f 3 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/100-port_listening_on_localhost: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Listens on port 98 on localhost. 3 | 4 | nc -l localhost 98 5 | -------------------------------------------------------------------------------- /0x02-shell_redirections/103-the_biggest_fan: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | tail -n +2 | cut -f -1 | sort -k 1 | uniq -c | sort -rnk 1 | head -n 11 | rev | cut -d ' ' -f -1 | rev 3 | -------------------------------------------------------------------------------- /0x0B-ssh/0-use_a_private_key: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Connects to server 52.86.122.88 with key in ~/.ssh/school 3 | 4 | ssh -i ~/.ssh/school ubuntu@52.86.122.88 5 | -------------------------------------------------------------------------------- /0x0A-configuration_management/2-execute_a_command.pp: -------------------------------------------------------------------------------- 1 | # kill process killmenow 2 | 3 | exec { 'pkill': 4 | command => 'pkill killmenow', 5 | provider => 'shell', 6 | } 7 | -------------------------------------------------------------------------------- /0x0D-web_stack_debugging_0/0-give_me_a_page: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # run apache 3 | 4 | echo "ServerName localhost" >> /etc/apache2/apache2.conf 5 | service apache2 start 6 | -------------------------------------------------------------------------------- /0x00-shell_basics/.0-current_working_directory.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abdallah-sameh-ragab/alx-system_engineering-devops/master/0x00-shell_basics/.0-current_working_directory.swp -------------------------------------------------------------------------------- /0x08-networking_basics_2/1-show_attached_IPs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays all acive IPv4 addresses. 3 | 4 | ifconfig | grep -Eo "inet (addr:)?([0-9]*\.){3}[0-9]*" | cut -b 11- 5 | -------------------------------------------------------------------------------- /0x09-web_infrastructure_design/0-simple_web_stack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abdallah-sameh-ragab/alx-system_engineering-devops/master/0x09-web_infrastructure_design/0-simple_web_stack.png -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/1-for_best_school: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays 'Best School' in stdout 10 times 3 | 4 | for (( i=0; i<10; i++ )) 5 | do 6 | echo "Best School" 7 | done 8 | -------------------------------------------------------------------------------- /0x03-shell_variables_expansions/103-water_and_stir: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo $(printf %o $(($((5#$(echo $WATER | tr 'water' '01234'))) + $((5#$(echo $STIR | tr 'stir.' '01234'))))) | tr '01234567' 'bestchol') 3 | -------------------------------------------------------------------------------- /0x09-web_infrastructure_design/1-distributed_web_infrastructure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abdallah-sameh-ragab/alx-system_engineering-devops/master/0x09-web_infrastructure_design/1-distributed_web_infrastructure.png -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/102-lets_parse_apache_logs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Parses Apache log files in list format. 3 | # Displays the IP and HTTP status code. 4 | # . 5 | 6 | awk '{print $1 " " $9}' apache-access.log -------------------------------------------------------------------------------- /0x07-networking_basics/4-TCP_and_UDP_ports: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays listening ports. Includes listening sockets too 3 | # + as the PID and name of the program to which each socket belongs. 4 | 5 | netstat -l --program 6 | -------------------------------------------------------------------------------- /0x0A-configuration_management/0-create_a_file.pp: -------------------------------------------------------------------------------- 1 | # creates a file in /tmp 2 | 3 | file { '/tmp/school': 4 | content =>'I love Puppet', 5 | mode => '0744', 6 | owner => 'www-data', 7 | group => 'www-data', 8 | } 9 | -------------------------------------------------------------------------------- /0x09-web_infrastructure_design/2-secured_and_monitored_web_infrastructure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abdallah-sameh-ragab/alx-system_engineering-devops/master/0x09-web_infrastructure_design/2-secured_and_monitored_web_infrastructure.png -------------------------------------------------------------------------------- /0x0E-web_stack_debugging_1/1-debugging_made_short: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #Sets nginx for listening to 80 port 3 | sed -i "s/8080/80/" /etc/nginx/sites-enabled/default 4 | sudo service nginx restart 5 | kill -9 "$(cat /var/run/nginx.pid)" 6 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/2-while_best_school: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays 'Best School' in stdout 10 times using a while loop 3 | 4 | index=0 5 | 6 | while [ $index -lt 10 ] 7 | do 8 | echo "Best School" 9 | ((index++)) 10 | done 11 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/3-until_best_school: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays 'Best School' in stdout 10 times using the until loop 3 | 4 | index=0 5 | 6 | until [ $index -eq 10 ] 7 | do 8 | echo "Best School" 9 | ((index++)) 10 | done 11 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/8-for_ls: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays the contents of the current directory in list format. 3 | # Only displays the part of the name after the first dash. 4 | 5 | list=$(ls) 6 | for i in $list; do 7 | echo "$i" | cut -d '-' -f2 8 | done 9 | -------------------------------------------------------------------------------- /0x07-networking_basics/5-is_the_host_on_the_network: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Pings an IP address received as a string argument 5 times. 3 | 4 | if [ "$#" -eq 0 ] 5 | then 6 | echo "Usage: 5-is_the_host_on_the_network {IP_ADDRESS}" 7 | else 8 | ping -c 5 "$1" 9 | fi 10 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/100-read_and_cut: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays the contents of the file `/etc/passwd`. 3 | # Only displays the username, user id, and user home directory path. 4 | 5 | while read -r passwd; do 6 | echo "$passwd" | cut -d ':' -f1,3,6 7 | done < "/etc/passwd" 8 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/4-if_9_say_hi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays 'Best School'. Displays Hi on the 9th iteration 3 | 4 | index=0 5 | 6 | while [ $index -lt 10 ] 7 | do 8 | if [ $index -eq 9 ] 9 | then 10 | echo "Hi" 11 | fi 12 | echo "Best School" 13 | (( index++ )) 14 | done 15 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/0-change_your_home_IP: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Configures an Ubuntu server as follows: 3 | # - localhost resolves to 127.0.0.2 4 | # - facebook.com resolves to 8.8.8.8 5 | 6 | cp /etc/hosts ~/hosts.new 7 | sed -i 's/127.*$/127.0.0.2 localhost\n8.8.8.8 facebook.com/' ~/hosts.new 8 | cp -f ~/hosts.new /etc/hosts 9 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/103-dig_the-data: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Parses Apache log files in list format. 3 | # Groups visitors by IP and HTTP status code. 4 | # Displays the number of occurrences, IP, and HTTP status 5 | #+ code of each log, in sorted order. 6 | 7 | awk '{ print $1 " " $9}' apache-access.log | sort | uniq -c | sort -rn 8 | -------------------------------------------------------------------------------- /0x0F-load_balancer/2-puppet_custom_http_response_header.pp: -------------------------------------------------------------------------------- 1 | # Automation: creates a custom HTTP header response with Puppet. 2 | exec { 'command': 3 | command => 'apt-get -y update; 4 | apt-get -y install nginx; 5 | sudo sed -i "/listen 80 default_server;/a add_header X-Served-By $HOSTNAME;" /etc/nginx/sites-available/default; 6 | service nginx restart', 7 | provider => shell, 8 | } 9 | -------------------------------------------------------------------------------- /0x0C-web_server/1-install_nginx_web_server: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This script installs and configures the Nginx web server. 3 | # It updates the package list, installs Nginx, creates a basic HTML file, 4 | # and starts the Nginx service. 5 | 6 | sudo apt-get -y update 7 | sudo apt-get -y install nginx 8 | echo 'Hello World!' > /var/www/html/index.nginx-debian.html 9 | sudo service nginx start 10 | -------------------------------------------------------------------------------- /0x13-firewall/0-block_all_incoming_traffic_but: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Configures a ufw firewall to block all incoming traffic 3 | #+ except for TCP ports 22, 443 and 80. 4 | 5 | apt-get install ufw 6 | sed -i 's/IPV6=.*/IPV6=yes/' /etc/default/ufw 7 | ufw disable 8 | ufw enable 9 | ufw default deny incoming 10 | ufw default allow outgoing 11 | ufw allow 22/tcp 12 | ufw allow 443/tcp 13 | ufw allow 80/tcp 14 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/7-clock: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays the time for 12 horus and 59 minutes. 3 | # Displays hours from 0 to 12 4 | # Displays minutes from 1 to 59 5 | 6 | hour=0 7 | 8 | while [ $hour -le 12 ] 9 | do 10 | echo "Hour: $hour" 11 | minute=1 12 | while [ $minute -le 59 ] 13 | do 14 | echo "$minute" 15 | (( minute++ )) 16 | done 17 | (( hour++ )) 18 | done 19 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/101-tell_the_story_of_passwd: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Tells a story based on the contents of the `/etc/passwd` file. 3 | 4 | while IFS=':' read -r username password uid gid info home shell; do 5 | echo "The user $username is part of the $gid gang,"\ 6 | "lives in $home and rides $shell."\ 7 | "$uid's place is protected by the passcode $password,"\ 8 | "more info about the user here: $info" 9 | done < "/etc/passwd" 10 | -------------------------------------------------------------------------------- /0x0B-ssh/100-puppet_ssh_config.pp: -------------------------------------------------------------------------------- 1 | # Setting up my client config file 2 | include stdlib 3 | 4 | file_line { 'Turn off passwd auth': 5 | ensure => present, 6 | path => '/etc/ssh/ssh_config', 7 | line => ' PasswordAuthentication no', 8 | replace => true, 9 | } 10 | 11 | file_line { 'Declare identity file': 12 | ensure => present, 13 | path => '/etc/ssh/ssh_config', 14 | line => ' IdentityFile ~/.ssh/school', 15 | replace => true, 16 | } 17 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/9-to_file_or_not_to_file: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays information about the file `school`. 3 | 4 | if [ -e "school" ] 5 | then 6 | echo "school file exists" 7 | if [ -s "school" ] 8 | then 9 | echo "school file is not empty" 10 | else 11 | echo "school file is empty" 12 | fi 13 | 14 | if [ -f "school" ] 15 | then 16 | echo "school is a regular file" 17 | fi 18 | else 19 | echo "school file does not exist" 20 | fi 21 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/5-4_bad_luck_8_is_your_chance: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Loops from 1 to 10 and displays: 3 | # "bad luck" for the 4th iteration 4 | # "good luck" for the 8th iteration 5 | # "Best School" for all other iterations 6 | 7 | count=0 8 | 9 | while [ $count -lt 10 ] 10 | do 11 | if [ $count -eq 3 ] 12 | then 13 | echo "bad luck" 14 | elif [ $count -eq 7 ] 15 | then 16 | echo "good luck" 17 | else 18 | echo "Best School" 19 | fi 20 | (( count++ )) 21 | done 22 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/6-superstitious_numbers: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays numbers from 1 to 20 in addition to: 3 | # "bad luck from China" for the 4th iteration 4 | # "bad luck from Japan" for the 9th iteration 5 | # "bad luck from Italy" for the 17th loop iteration 6 | 7 | count=1 8 | 9 | while [ $count -le 20 ] 10 | do 11 | echo "$count" 12 | case $count in 13 | "4") echo "bad luck from China";; 14 | "9") echo "bad luck from Japan";; 15 | "17") echo "bad luck from Italy";; 16 | esac 17 | (( count++ )) 18 | done 19 | -------------------------------------------------------------------------------- /0x10-https_ssl/0-world_wide_web: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Takes a subdomain and a domain and returns information about the subdomain 3 | 4 | print_info () { 5 | dig "$1" | grep -A1 'ANSWER SECTION:' | sed -r "s/$1./$2/g" | awk -F" " ' NR==2 { print "The subdomain " $1 " is a " $4 " record and points to " $5 }' 6 | } 7 | 8 | if [ "$#" -eq 2 ] 9 | then 10 | print_info "$2.$1" "$2" 11 | else 12 | print_info "www.$1" "www" 13 | print_info "lb-01.$1" "lb-01" 14 | print_info "web-01.$1" "web-01" 15 | print_info "web-02.$1" "web-02" 16 | fi 17 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/0-RSA_public_key.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC+5UGlRueiWjKch7Y/EFzc5q1J2CIZOF3S58zLAnmRxpMndQZ+aB/kNdmj+BfUUVylUaU4o+mPU94W+uyMdARvunPfx5330s89wIv4b5XrokTCB0Wjo7NPwkm+OiRHOCinJlEYbDCaFQiA8ZLJ0Gac5kJ8PZkF+MhHxqKFDWqdjnRb3OBpO8s4VkIBeSQC+W/5ZID53XxU8+uwZow/iJ9HEQxmw/ODeidcukCo9CkapkYAT0wOzC3GuZEsb73P+IVe70o5JwDRjh5puLdqXaV0mq4Km7HHk/QIzAKv5MZKqiQ94iBSX/UG2q660t4vQO8xoPc9m6FSEraP7p9+Po+TultU81ZhtiwvyNRqvJTEklLJ2wWA4Uzz3xOt5IvqRdGiLXGFFbhAGrtDWHnK/FTaQDGq+KPXZ21EKa5JVHw00BXzWjZQ9g1iAntSmWIBSqW/jP7Olj5vX6JmP9x16x5OteohJ4xSJxubGQ3I5wSWsZa4R+gxeIKkewcqsqrCKCE= BigBoss@Administrator 2 | -------------------------------------------------------------------------------- /0x13-firewall/README.md: -------------------------------------------------------------------------------- 1 | # Firewall 2 | 3 | In this project, I used `ufw` to configure firewalls on my issued web servers. 4 | 5 | ## Tasks :page_with_curl: 6 | 7 | * **0. Block all incoming traffic but** 8 | * [0-block_all_incoming_traffic_but](./0-block_all_incoming_traffic_but): Bash 9 | script that installs a `ufw` firewall to block all incoming traffic except for 10 | ports `22`, `443` and `80` on a web server. 11 | 12 | * **1. Port forwarding** 13 | * [100-port_forwarding](./100-port_forwarding): `ufw` configuration file that 14 | configures a firewall to redirect port `8080/TCP` to port `80/TCP`. 15 | -------------------------------------------------------------------------------- /0x04-loops_conditions_and_parsing/10-fizzbuzz: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Displays numbers from 1 to 100 in list format. 3 | # Displays "FizzBuzz" when the number is a multiple of 3 and 5. 4 | # Displays "Fizz" when the number is a multiple of 3. 5 | # Displays "Buzz" when the number is a multiple of 5. 6 | # Otherwise, displays the number. 7 | 8 | for num in {1..100} 9 | do 10 | if (( num % 3 == 0 && num % 5 == 0 )) 11 | then 12 | echo "FizzBuzz" 13 | elif (( num % 3 == 0 )) 14 | then 15 | echo "Fizz" 16 | elif (( num % 5 == 0 )) 17 | then 18 | echo "Buzz" 19 | else 20 | echo "$num" 21 | fi 22 | done 23 | -------------------------------------------------------------------------------- /0x0A-configuration_management/1-install_a_package.pp: -------------------------------------------------------------------------------- 1 | # Ensure pip is installed 2 | package { 'python3-pip': 3 | ensure => installed, 4 | } 5 | 6 | # Install Flask 2.1.0 7 | exec { 'install_flask': 8 | command => '/usr/bin/pip3 install Flask==2.1.0', 9 | creates => '/usr/local/lib/python3.8/dist-packages/Flask-2.1.0.dist-info', 10 | require => Package['python3-pip'], 11 | } 12 | 13 | # Install Werkzeug 2.2.2 14 | exec { 'install_werkzeug': 15 | command => '/usr/bin/pip3 install Werkzeug==2.2.2', 16 | creates => '/usr/local/lib/python3.8/dist-packages/Werkzeug-2.2.2.dist-info', 17 | require => Package['python3-pip'], 18 | } 19 | -------------------------------------------------------------------------------- /0x0C-web_server/3-redirection: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Update the package repository 3 | sudo apt-get -y update 4 | 5 | # Install Nginx web server 6 | sudo apt-get -y install nginx 7 | 8 | # Allow incoming HTTP traffic 9 | sudo ufw allow 'Nginx HTTP' 10 | 11 | # Create index.html file with "Hello World" content 12 | echo "Hello World" | sudo tee /var/www/html/index 13 | 14 | # Add redirection rule to Nginx configuration 15 | sudo sed -i '/listen 80 default_server/a rewrite ^/redirect_me https://www.youtube.com/watch?v=QH2-TGUlwu4 permanent;' /etc/nginx/sites-available/default 16 | 17 | # Restart Nginx service 18 | sudo service nginx restart 19 | -------------------------------------------------------------------------------- /0x15-api/0-gather_data_from_an_API.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """Returns to-do list information for a given employee ID.""" 3 | import requests 4 | import sys 5 | 6 | if __name__ == "__main__": 7 | url = "https://jsonplaceholder.typicode.com/" 8 | user = requests.get(url + "users/{}".format(sys.argv[1])).json() 9 | todos = requests.get(url + "todos", params={"userId": sys.argv[1]}).json() 10 | 11 | completed = [t.get("title") for t in todos if t.get("completed") is True] 12 | print("Employee {} is done with tasks({}/{}):".format( 13 | user.get("name"), len(completed), len(todos))) 14 | [print("\t {}".format(c)) for c in completed] 15 | -------------------------------------------------------------------------------- /0x0C-web_server/0-transfer_file: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This script transfers a file to a remote server using SCP. 3 | # It requires four arguments: 4 | # - PATH_TO_FILE: the local path to the file to be transferred 5 | # - IP: the IP address of the remote server 6 | # - USERNAME: the username for the remote server 7 | # - PATH_TO_SSH_KEY: (optional) the path to the SSH key for authentication 8 | 9 | if [ $# -lt 3 ]; 10 | then 11 | echo "Usage: 0-transfer_file PATH_TO_FILE IP USERNAME PATH_TO_SSH_KEY"; 12 | exit; 13 | fi; 14 | 15 | if [ $# -ge 4 ]; 16 | then 17 | scp -o StrictHostKeyChecking=no -i "$4" "$1" "$3"@"$2":~/ 18 | else 19 | scp -o StrictHostKeyChecking=no "$1" "$3"@"$2":~/ 20 | fi; 21 | -------------------------------------------------------------------------------- /0x15-api/1-export_to_CSV.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """Exports to-do list information for a given employee ID to CSV format.""" 3 | import csv 4 | import requests 5 | import sys 6 | 7 | if __name__ == "__main__": 8 | user_id = sys.argv[1] 9 | url = "https://jsonplaceholder.typicode.com/" 10 | user = requests.get(url + "users/{}".format(user_id)).json() 11 | username = user.get("username") 12 | todos = requests.get(url + "todos", params={"userId": user_id}).json() 13 | 14 | with open("{}.csv".format(user_id), "w", newline="") as csvfile: 15 | writer = csv.writer(csvfile, quoting=csv.QUOTE_ALL) 16 | [writer.writerow( 17 | [user_id, username, t.get("completed"), t.get("title")] 18 | ) for t in todos] 19 | -------------------------------------------------------------------------------- /0x15-api/3-dictionary_of_list_of_dictionaries.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """Exports to-do list information of all employees to JSON format.""" 3 | import json 4 | import requests 5 | 6 | if __name__ == "__main__": 7 | url = "https://jsonplaceholder.typicode.com/" 8 | users = requests.get(url + "users").json() 9 | 10 | with open("todo_all_employees.json", "w") as jsonfile: 11 | json.dump({ 12 | u.get("id"): [{ 13 | "task": t.get("title"), 14 | "completed": t.get("completed"), 15 | "username": u.get("username") 16 | } for t in requests.get(url + "todos", 17 | params={"userId": u.get("id")}).json()] 18 | for u in users}, jsonfile) 19 | -------------------------------------------------------------------------------- /0x15-api/2-export_to_JSON.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """Exports to-do list information for a given employee ID to JSON format.""" 3 | import json 4 | import requests 5 | import sys 6 | 7 | if __name__ == "__main__": 8 | user_id = sys.argv[1] 9 | url = "https://jsonplaceholder.typicode.com/" 10 | user = requests.get(url + "users/{}".format(user_id)).json() 11 | username = user.get("username") 12 | todos = requests.get(url + "todos", params={"userId": user_id}).json() 13 | 14 | with open("{}.json".format(user_id), "w") as jsonfile: 15 | json.dump({user_id: [{ 16 | "task": t.get("title"), 17 | "completed": t.get("completed"), 18 | "username": username 19 | } for t in todos]}, jsonfile) 20 | -------------------------------------------------------------------------------- /0x0F-load_balancer/1-install_load_balancer: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Configure Nginx so that its HTTP response contains 3 | # a custom header 4 | # 5 | balancer="\ 6 | frontend haproxy_balancer 7 | bind *:80 8 | mode http 9 | default_backend webservers 10 | 11 | backend webservers 12 | balance roundrobin 13 | server 486690-web-01 52.86.122.88:80 check 14 | server 486690-web-02 18.235.249.198:80 check 15 | " 16 | # Update packages 17 | apt-get -y update 18 | apt-get -y upgrade 19 | 20 | # Add HAProxy PPA 21 | apt-get -y install software-properties-common 22 | add-apt-repository -y ppa:vbernat/haproxy-2.5 23 | apt-get -y update 24 | 25 | # Install HAProxy 26 | apt-get -y install haproxy 27 | cp -a /etc/haproxy/haproxy.cfg{,.orig} 28 | echo "$balancer" >> /etc/haproxy/haproxy.cfg 29 | service haproxy restart 30 | -------------------------------------------------------------------------------- /0x08-networking_basics_2/README.md: -------------------------------------------------------------------------------- 1 | # Networking basics #1 2 | 3 | This project was the second of two introducing networking. I continued to learn 4 | about IP addresses while practicing manipulating them with Bash scripts. 5 | 6 | ## Tasks :page_with_curl: 7 | 8 | * **0. Change your home IP** 9 | * [0-change_your_home_IP](./0-change_your_home_IP): Bash script that configures 10 | an Ubuntu server as follows: 11 | * `localhost` resolves to `127.0.0.2` 12 | * `facebook.com` resolves to `8.8.8.8` 13 | 14 | * **1. Show attached IPs** 15 | * [1-show_attached_IPs](./1-show_attached_IPs): Bash script that displays all active IPv4 16 | IP's on the machine. 17 | 18 | * **2. Port listening on localhost** 19 | * [100-port_listening_on_localhost](./100-port_listening_on_localhost): Bash script that 20 | listens on port `98` on `localhost`. 21 | -------------------------------------------------------------------------------- /0x0C-web_server/4-not_found_page_404: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This script installs and configures Nginx web server, sets up a custom 404 page, 3 | # and adds a redirect rule to the default Nginx configuration. 4 | 5 | apt-get -y update 6 | apt-get -y install nginx 7 | 8 | # Create a basic "Hello World!" index.html file 9 | echo "Hello World!" | sudo tee /var/www/html/index.html > /dev/null 10 | 11 | # Add a redirect rule to the default Nginx configuration 12 | sed -i "46i rewrite ^/redirect_me https://www.youtube.com/watch?v=QH2-TGUlwu4 permanent;" /etc/nginx/sites-available/default 13 | 14 | # Create a custom 404.html file 15 | echo "Ceci n'est pas une page" | sudo tee /var/www/html/custom_404.html > /dev/null 16 | 17 | # Set up the custom 404 page in the Nginx configuration 18 | sed -i "46i error_page 404 /custom_404.html;" /etc/nginx/sites-available/default 19 | 20 | # Restart the Nginx service to apply the changes 21 | service nginx restart -------------------------------------------------------------------------------- /0x0F-load_balancer/0-custom_http_response_header: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Installs Nginx with the following configurations: 3 | #+ Listens on port 80. 4 | #+ Returns a page containing "Hello World" when queried 5 | #+ at the root with a curl GET request. 6 | #+ Configures /redirect_me as a "301 Moved Permanently". 7 | #+ Includes a custom 404 page containing "Ceci n'est pas une page". 8 | #+ Contains a custom HTTP header named X-Served-By. 9 | #+ The value of the HTTP header is the hostname of the running server. 10 | 11 | apt-get update 12 | apt-get install -y nginx 13 | 14 | mkdir -p /var/www/html 15 | touch /var/www/html/index.html 16 | echo "Hello World X-Served-By" > /var/www/html/index.html 17 | touch /var/www/html/404.html 18 | echo "Ceci n'est pas une page" > /var/www/html/404.html 19 | 20 | printf %s "server { 21 | listen 80 default_server; 22 | listen [::]:80 default_server; 23 | add_header X-Served-By $HOSTNAME; 24 | root /var/www/html; 25 | index index.html index.htm; 26 | 27 | location /redirect_me { 28 | return 301 http://cuberule.com/; 29 | } 30 | 31 | error_page 404 /404.html; 32 | location /404 { 33 | root /var/www/html; 34 | internal; 35 | } 36 | }" > /etc/nginx/sites-available/default 37 | 38 | service nginx restart 39 | -------------------------------------------------------------------------------- /0x0E-web_stack_debugging_1/0-nginx_likes_port_80: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # fix nginx listening on port 80 3 | # Go to sites-enabled folder for Nginx 4 | cd /etc/nginx/sites-enabled/ || exit; 5 | # Delete the default file 6 | rm default; 7 | # Create symbolic link to the deafult file in sites-available 8 | ln -s /etc/nginx/sites-available/default default; 9 | # Restart Nginx 10 | service nginx restart 11 | -------------------------------------------------------------------------------- /0x10-https_ssl/1-haproxy_ssl_termination: -------------------------------------------------------------------------------- 1 | global 2 | log /dev/log local0 3 | log /dev/log local1 notice 4 | chroot /var/lib/haproxy 5 | stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners 6 | stats timeout 30s 7 | user haproxy 8 | group haproxy 9 | daemon 10 | 11 | # Default SSL material locations 12 | ca-base /etc/ssl/certs 13 | crt-base /etc/ssl/private 14 | 15 | # See: https://ssl-config.mozilla.org/#server=haproxy&server-version=2.0.3&config=intermediate 16 | ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384 17 | ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256 18 | ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets 19 | 20 | defaults 21 | log global 22 | mode http 23 | option httplog 24 | option dontlognull 25 | timeout connect 5000 26 | timeout client 50000 27 | timeout server 50000 28 | errorfile 400 /etc/haproxy/errors/400.http 29 | errorfile 403 /etc/haproxy/errors/403.http 30 | errorfile 408 /etc/haproxy/errors/408.http 31 | errorfile 500 /etc/haproxy/errors/500.http 32 | errorfile 502 /etc/haproxy/errors/502.http 33 | errorfile 503 /etc/haproxy/errors/503.http 34 | errorfile 504 /etc/haproxy/errors/504.http 35 | 36 | frontend ragab.tech-http-frontend 37 | bind *:80 38 | bind *:443 ssl crt /etc/letsencrypt/live/ragab.tech/fullchain.pem 39 | http-request set-header X-Forwarded-Proto https 40 | default_backend webservers 41 | 42 | backend webservers 43 | balance roundrobin 44 | server 486690-web-01 52.86.122.88:80 check 45 | server 486690-web-02 18.235.249.198:80 check -------------------------------------------------------------------------------- /0x09-web_infrastructure_design/0-simple_web_stack.md: -------------------------------------------------------------------------------- 1 | # 0-simple_web_stack 2 | ![](./0-simple_web_stack.png) 3 | 4 | ## Requirements: 5 | - 1 server 6 | - 1 web server (Nginx) 7 | - 1 application server 8 | - 1 application files (your code base) 9 | - 1 database (MySQL) 10 | - 1 domain name foobar.com configured with a www record that points to your server IP 8.8.8.8 11 | 12 | ## Issues with this Infrastructure : 13 | - Single Point of Failure (SPOF): 14 | The infrastructure has a single server, which introduces a potential single point of failure. 15 | If the server goes down, the entire website becomes inaccessible. 16 | 17 | - Downtime During Maintenance: 18 | When maintenance is needed, such as deploying new code that requires restarting the web server, 19 | there may be downtime during the restart. 20 | 21 | - The current infrastructure may struggle to handle a large amount of incoming traffic. 22 | implementing load balancing, and having a microservices structure might help with scaling. 23 | 24 | ## Questions : 25 | - Server: is a computer or system that provides services or resources to other computers (clients), over a network. 26 | In this case, the server hosts the web infrastructure. 27 | 28 | - The role of the domain name (www.foobar.com) is to provide a human-readable alias for the server's IP address (8.8.8.8). 29 | 30 | - The DNS record for www in www.foobar.com is a CNAME (Canonical Name) record. 31 | 32 | - The role of the web server (Nginx) is to handle incoming HTTP requests and serve static content to users. 33 | It can also act as a reverse proxy to forward dynamic requests to the application server. 34 | 35 | - The application server hosts the application codebase. It processes dynamic content, executes business logic, 36 | and communicates with other parts of the infrastructure, such as the database. 37 | 38 | - The role of the database (MySQL) is to store and manage the website's data. 39 | It can be queried and updated by the application server based on user requests. 40 | 41 | - The server communicates with the user's computer using the HTTP protocol. -------------------------------------------------------------------------------- /0x10-https_ssl/100-redirect_http_to_https: -------------------------------------------------------------------------------- 1 | global 2 | log /dev/log local0 3 | log /dev/log local1 notice 4 | chroot /var/lib/haproxy 5 | stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners 6 | stats timeout 30s 7 | user haproxy 8 | group haproxy 9 | daemon 10 | 11 | # Default SSL material locations 12 | ca-base /etc/ssl/certs 13 | crt-base /etc/ssl/private 14 | 15 | # See: https://ssl-config.mozilla.org/#server=haproxy&server-version=2.0.3&config=intermediate 16 | ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384 17 | ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256 18 | ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets 19 | 20 | defaults 21 | log global 22 | mode http 23 | option httplog 24 | option dontlognull 25 | timeout connect 5000 26 | timeout client 50000 27 | timeout server 50000 28 | errorfile 400 /etc/haproxy/errors/400.http 29 | errorfile 403 /etc/haproxy/errors/403.http 30 | errorfile 408 /etc/haproxy/errors/408.http 31 | errorfile 500 /etc/haproxy/errors/500.http 32 | errorfile 502 /etc/haproxy/errors/502.http 33 | errorfile 503 /etc/haproxy/errors/503.http 34 | errorfile 504 /etc/haproxy/errors/504.http 35 | 36 | frontend ragab.tech-http-frontend 37 | bind *:80 38 | bind *:443 ssl crt /etc/letsencrypt/live/ragab.tech/fullchain.pem 39 | redirect scheme https code 301 if !{ ssl_fc } 40 | http-request set-header X-Forwarded-Proto https 41 | default_backend webservers 42 | 43 | backend webservers 44 | balance roundrobin 45 | server 486690-web-01 52.86.122.88:80 check 46 | server 486690-web-02 18.235.249.198:80 check -------------------------------------------------------------------------------- /0x13-firewall/100-port_forwarding: -------------------------------------------------------------------------------- 1 | # 2 | # rules.before 3 | # 4 | # Rules that should be run before the ufw command line added rules. Custom 5 | # rules should be added to one of these chains: 6 | # ufw-before-input 7 | # ufw-before-output 8 | # ufw-before-forward 9 | # 10 | 11 | *nat 12 | :PREROUTING ACCEPT [0:0] 13 | -A PREROUTING -p tcp --dport 8080 -j REDIRECT --to-port 80 14 | 15 | # Don't delete these required lines, otherwise there will be errors 16 | *filter 17 | :ufw-before-input - [0:0] 18 | :ufw-before-output - [0:0] 19 | :ufw-before-forward - [0:0] 20 | :ufw-not-local - [0:0] 21 | # End required lines 22 | 23 | 24 | # allow all on loopback 25 | -A ufw-before-input -i lo -j ACCEPT 26 | -A ufw-before-output -o lo -j ACCEPT 27 | 28 | # quickly process packets for which we already have a connection 29 | -A ufw-before-input -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 30 | -A ufw-before-output -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 31 | -A ufw-before-forward -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 32 | 33 | # drop INVALID packets (logs these in loglevel medium and higher) 34 | -A ufw-before-input -m conntrack --ctstate INVALID -j ufw-logging-deny 35 | -A ufw-before-input -m conntrack --ctstate INVALID -j DROP 36 | 37 | # ok icmp codes for INPUT 38 | -A ufw-before-input -p icmp --icmp-type destination-unreachable -j ACCEPT 39 | -A ufw-before-input -p icmp --icmp-type source-quench -j ACCEPT 40 | -A ufw-before-input -p icmp --icmp-type time-exceeded -j ACCEPT 41 | -A ufw-before-input -p icmp --icmp-type parameter-problem -j ACCEPT 42 | -A ufw-before-input -p icmp --icmp-type echo-request -j ACCEPT 43 | 44 | # ok icmp code for FORWARD 45 | -A ufw-before-forward -p icmp --icmp-type destination-unreachable -j ACCEPT 46 | -A ufw-before-forward -p icmp --icmp-type source-quench -j ACCEPT 47 | -A ufw-before-forward -p icmp --icmp-type time-exceeded -j ACCEPT 48 | -A ufw-before-forward -p icmp --icmp-type parameter-problem -j ACCEPT 49 | -A ufw-before-forward -p icmp --icmp-type echo-request -j ACCEPT 50 | 51 | # allow dhcp client to work 52 | -A ufw-before-input -p udp --sport 67 --dport 68 -j ACCEPT 53 | 54 | # 55 | # ufw-not-local 56 | # 57 | -A ufw-before-input -j ufw-not-local 58 | 59 | # if LOCAL, RETURN 60 | -A ufw-not-local -m addrtype --dst-type LOCAL -j RETURN 61 | 62 | # if MULTICAST, RETURN 63 | -A ufw-not-local -m addrtype --dst-type MULTICAST -j RETURN 64 | 65 | # if BROADCAST, RETURN 66 | -A ufw-not-local -m addrtype --dst-type BROADCAST -j RETURN 67 | 68 | # all other non-local packets are dropped 69 | -A ufw-not-local -m limit --limit 3/min --limit-burst 10 -j ufw-logging-deny 70 | -A ufw-not-local -j DROP 71 | 72 | # allow MULTICAST mDNS for service discovery (be sure the MULTICAST line above 73 | # is uncommented) 74 | -A ufw-before-input -p udp -d 224.0.0.251 --dport 5353 -j ACCEPT 75 | 76 | # allow MULTICAST UPnP for service discovery (be sure the MULTICAST line above 77 | # is uncommented) 78 | -A ufw-before-input -p udp -d 239.255.255.250 --dport 1900 -j ACCEPT 79 | 80 | # don't delete the 'COMMIT' line or these rules won't be processed 81 | COMMIT 82 | -------------------------------------------------------------------------------- /0x09-web_infrastructure_design/1-distributed_web_infrastructure.md: -------------------------------------------------------------------------------- 1 | # 1-distributed_web_infrastructure 2 | 3 | ![](./1-distributed_web_infrastructure.png) 4 | 5 | ## Requirements: 6 | - 2 servers 7 | - 1 web server (Nginx) 8 | - 1 application server 9 | - 1 load-balancer (HAproxy) 10 | - 1 set of application files (your code base) 11 | - 1 database (MySQL) 12 | 13 | ## Issues with this Infrastructure : 14 | - Single Points of Failure (SPOFs): 15 | The Load Balancer can be a single point of failure. 16 | If it goes down, the entire website becomes inaccessible. 17 | - Security issues (no firewall, no HTTPS): 18 | The infrastructure has no firewall. 19 | This exposes the servers to security threats. 20 | The website also does not use HTTPS, which is a security risk. 21 | - No monitoring: 22 | There is no monitoring configured for the infrastructure. 23 | This means that it will be difficult to debug issues or to pinpoint performance bottlenecks. 24 | 25 | ## Questions : 26 | Why added a load balancer? 27 | - Load balancing distributes traffic across multiple servers. 28 | This helps with redundancy (no single point of failure), and with scaling the infrastructure to handle larger amounts of traffic. 29 | a load balancer can also help with security by offloading some tasks to the load balancer, such as filtering traffic by IP. 30 | 31 | What distribution algorithm your load balancer is configured with and how it works ? 32 | - The load balancer is configured with a round-robin algorithm. 33 | This means that it will distribute traffic evenly across the servers. 34 | Other algorithms include least connections and least response time. 35 | Least connections will prioritize servers with fewer active connections. 36 | Least response time will prioritize servers with the lowest average response time. 37 | 38 | Is your load-balancer enabling an Active-Active or Active-Passive setup, explain the difference between both ? 39 | - The load balancer is configured with an Active-Passive setup. 40 | This means that only one server will be active at any given time. 41 | The passive server will only become active if the active server goes down. 42 | An Active-Active setup would have both servers active at the same time. 43 | 44 | How a database Primary-Replica (Master-Slave) cluster works ? 45 | - The primary-replica cluster consists of two servers. 46 | The primary server is the main server that handles all the database operations. 47 | The replica server is a backup server that can take over if the primary server goes down. 48 | The replica server is synchronized with the primary server to ensure it has the same data. 49 | The replica server can also be used to handle read-only traffic, such as SELECT queries. 50 | 51 | What is the difference between the Primary node and the Replica node in regard to the application ? 52 | - The primary node is the main server that handles all the database operations. 53 | The replica node is a backup server that can take over if the primary server goes down. 54 | The replica node is synchronized with the primary node to ensure it has the same data. 55 | The replica node can also be used to handle read-only traffic, such as SELECT queries. -------------------------------------------------------------------------------- /0x0C-web_server/7-puppet_install_nginx_web_server.pp: -------------------------------------------------------------------------------- 1 | # This Puppet manifest installs and configures Nginx web server on a Linux system. 2 | # It performs the following steps: 3 | # 1. Adds the stable version of Nginx repository. 4 | # 2. Updates the software packages list. 5 | # 3. Installs Nginx. 6 | # 4. Allows HTTP traffic through the firewall. 7 | # 5. Changes the permissions of the /var/www folder. 8 | # 6. Creates an index.html file in the /var/www/html directory. 9 | # 7. Creates a 404.html file in the /var/www/html directory. 10 | # 8. Configures the default Nginx server block to serve static files and handle 404 errors. 11 | # 9. Restarts the Nginx service. 12 | # 10. Ensures that the Nginx service is running. 13 | 14 | # Note: This Puppet manifest assumes that the system is running Ubuntu or a similar Debian-based distribution. 15 | 16 | # add stable version of nginx 17 | exec { 'add nginx stable repo': 18 | command => 'sudo add-apt-repository ppa:nginx/stable', 19 | path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 20 | } 21 | 22 | # update software packages list 23 | exec { 'update packages': 24 | command => 'apt-get update', 25 | path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 26 | } 27 | 28 | # install nginx 29 | package { 'nginx': 30 | ensure => 'installed', 31 | } 32 | 33 | # allow HTTP 34 | exec { 'allow HTTP': 35 | command => "ufw allow 'Nginx HTTP'", 36 | path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 37 | onlyif => '! dpkg -l nginx | egrep \'îi.*nginx\' > /dev/null 2>&1', 38 | } 39 | 40 | # change folder rights 41 | exec { 'chmod www folder': 42 | command => 'chmod -R 755 /var/www', 43 | path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 44 | } 45 | 46 | # create index file 47 | file { '/var/www/html/index.html': 48 | content => "Hello World!\n", 49 | } 50 | 51 | # create index file 52 | file { '/var/www/html/404.html': 53 | content => "Ceci n'est pas une page\n", 54 | } 55 | 56 | # add redirection and error page 57 | file { 'Nginx default config file': 58 | ensure => file, 59 | path => '/etc/nginx/sites-enabled/default', 60 | content => 61 | "server { 62 | listen 80 default_server; 63 | listen [::]:80 default_server; 64 | root /var/www/html; 65 | # Add index.php to the list if you are using PHP 66 | index index.html index.htm index.nginx-debian.html; 67 | server_name _; 68 | location / { 69 | # First attempt to serve request as file, then 70 | # as directory, then fall back to displaying a 404. 71 | try_files \$uri \$uri/ =404; 72 | } 73 | error_page 404 /404.html; 74 | location /404.html { 75 | internal; 76 | } 77 | 78 | if (\$request_filename ~ redirect_me){ 79 | rewrite ^ https://www.youtube.com/watch?v=QH2-TGUlwu4 permanent; 80 | } 81 | } 82 | ", 83 | } 84 | # restart nginx 85 | exec { 'restart service': 86 | command => 'service nginx restart', 87 | path => '/usr/bin:/usr/sbin:/bin', 88 | } 89 | 90 | # start service nginx 91 | service { 'nginx': 92 | ensure => running, 93 | require => Package['nginx'], 94 | } 95 | -------------------------------------------------------------------------------- /0x09-web_infrastructure_design/2-secured_and_monitored_web_infrastructure.md: -------------------------------------------------------------------------------- 1 | # 2-secured_and_monitored_web_infrastructure 2 | ![](./2-secured_and_monitored_web_infrastructure.png) 3 | 4 | ## Requirements: 5 | - 3 firewalls 6 | - 1 SSL certificate to serve www.foobar.com over HTTPS 7 | - 3 monitoring clients (data collector for Sumologic or other monitoring services) 8 | 9 | ## Issues with this Infrastructure : 10 | - Single Points of Failure (SPOFs): 11 | The Load Balancer can be a single point of failure. 12 | If it goes down, the entire website becomes inaccessible. 13 | - SSL termination at the load balancer level is an issue because it means that the traffic between the load balancer and the web servers is not encrypted. 14 | - Having only one MySQL server capable of accepting writes is an issue because it means that the database is a single point of failure. 15 | - Having servers with all the same components (database, web server and application server) might be a problem because it means that if one component goes down, the entire server goes down. 16 | 17 | 18 | ## Questions : 19 | Why add a monitoring server? 20 | - A monitoring server is used to collect data about the infrastructure. 21 | This data can be used to debug issues, to identify performance bottlenecks, and to plan for scaling. 22 | 23 | why add a firewall? 24 | - A firewall is used to filter traffic to and from the servers. 25 | This helps with security by blocking unwanted traffic, such as DDoS attacks. 26 | 27 | Why add a SSL certificate? 28 | - SSL certificate is used to serve the website over HTTPS. 29 | This helps with security by encrypting the traffic between the server and the user's computer. 30 | 31 | why is the traffic served over HTTPS? 32 | - serving the traffic over HTTPS helps with security by encrypting the traffic between the server and the user's computer. 33 | 34 | Why terminating SSL at the load balancer level is an issue? 35 | - Terminating SSL at the load balancer level is an issue because it means that the traffic between the load balancer and the web servers is not encrypted. 36 | This means that if an attacker gains access to the network, they can intercept the traffic between the load balancer and the web servers. 37 | 38 | Why having only one MySQL server capable of accepting writes is an issue? 39 | - Having only one MySQL server capable of accepting writes is an issue because it means that the database is a single point of failure. 40 | 41 | Why having servers with all the same components (database, web server and application server) might be a problem? 42 | - Having servers with all the same components might be a problem because it means that if one component goes down, the entire server goes down. 43 | also, it means that the servers are not optimized for their specific roles. 44 | 45 | what to do if you want to monitor your web server QPS? 46 | - To monitor the web server QPS, you can use a monitoring tool such as Datadog. 47 | This tool can be configured to collect data about the web server, such as the number of requests per second. 48 | 49 | how the monitoring tool is collecting data? 50 | - The monitoring tool is collecting data by running a monitoring client on each server. 51 | This client collects data about the server, such as CPU usage, memory usage, and disk usage. 52 | The agent then sends this data to the monitoring tool, which can be used to visualize the data and to set up alerts. 53 | -------------------------------------------------------------------------------- /0x07-networking_basics/README.md: -------------------------------------------------------------------------------- 1 | # Networking basics #0 2 | 3 | This project was the first of two introducing networking concepts. In this 4 | project, I answered a few quiz-like questions and wrote a couple bash scripts 5 | while learning about the OSI model, LAN and WAN networks, and TCP/UDP data 6 | transfer protocols. 7 | 8 | ## Tasks :page_with_curl: 9 | 10 | * **0. OSI model** 11 | * [0-OSI_model](./0-OSI_model): Text file answering the following questions: 12 | * What is the OSI model? 13 | 1. Set of specifications that network hardware manufacturers must respect 14 | 2. The OSI model is a conceptual model that characterizes the communication 15 | functions of a telecommunication system without regard to their underlying 16 | internal structure and technology. 17 | 3. The OSI model is a model that characterizes the communication functions 18 | of a telecommunication system with a strong regard for their underlying 19 | internal structure and technology. 20 | * How is the OSI model organized? 21 | 1. Alphabetically 22 | 2. From the lowest to the highest level 23 | 3. Randomly 24 | 25 | * **1. Types of network** 26 | * [1-types_of_network](./1-types_of_network): Text file answering the following questions: 27 | * What type of network a computer in local is connected to? 28 | 1. Internet 29 | 2. WAN 30 | 3. LAN 31 | * What type of network could connect an office in one building to another 32 | office in a building a few streets away? 33 | 1. Internet 34 | 2. WAN 35 | 3. LAN 36 | * What network do you use when you browse www.google.com from your 37 | smartphone (not connected to the Wifi)? 38 | 1. Internet 39 | 2. WAN 40 | 3. LAN 41 | 42 | * **2. MAC and IP address** 43 | * [2-MAC_and_IP_address](./2-MAC_and_IP_address): Text file answering the following questions: 44 | * What is a MAC address? 45 | 1. The name of a network interface 46 | 2. The unique identifier of a network interface 47 | 3. A network interface 48 | * What is an IP address? 49 | 1. Is to devices connected to a network what postal address is to houses 50 | 2. The unique identifier of a network interface 51 | 3. Is a number that network devices use to connect to networks 52 | 53 | * **3. UDP and TCP** 54 | * [3-UDP_and_TCP](./3-UDP_and_TCP): Text file answering the following questions 55 | (boxes refer to an image provided by ALX): 56 | * Which statement is correct for the TCP box: 57 | 1. It is a protocol that is transferring data in a slow way but surely 58 | 2. It is a protocol that is transferring data in a fast way and might loss 59 | data along in the process 60 | * Which statement is correct for the UDP box: 61 | 1. It is a protocol that is transferring data in a slow way but surely 62 | 2. It is a protocol that is transferring data in a fast way and might loss 63 | data along in the process 64 | * Which statement is correct for the TCP worker: 65 | 1. Have you received boxes x, y, z? 66 | 2. May I increase the rate at which I am sending you boxes? 67 | 68 | * **4. TCP and UDP ports** 69 | * [4-TCP_and_UDP_ports](./4-TCP_and_UDP_ports): Bash script that displays listening ports. 70 | * Only shows listening sockets. 71 | * Displays the PID and name of the program to which each socket belongs. 72 | 73 | * **5. Is the host on the network** 74 | * [5-is_the_host_on_the_network](./5-is_the_host_on_the_network): Bash script that 75 | pings an IP address received as an argument 5 times. 76 | * Usage: `5-is_the_host_on_the_network {IP_ADDRESS}`. 77 | --------------------------------------------------------------------------------