Transfer data throught the network Flashcards

1
Q

What are the three profiles of Nginx through the ufw firewall?

A
  1. Nginx HTTP: port 80, unencrypted web traffic.
  2. Nginx HTTPS: port 443, TLS/SSL encrypted traffic.
  3. Nginx Full: both Nginx HTTP and HTTPS.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

$ sudo ufw allow ‘[Nginx profile]’

A

Allow a specific Nginx profile through the ufw firewall.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

$ sudo ufw status

A

List the traffic allowed through ufw.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the purpose of an init system like systemd?

A

To initialize the components that must be started after the Linux kernel is booted. it is also used to manage services and daemons for the server at any point while the system is running.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

$ sudo systemctl start [application]

A

Start a systemd service, executing instructions in the service’s unit file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

$ sudo systemctl stop [application]

A

Stop a running systemd service.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

$ sudo systemctl restart [application]

A

Restart a systemd service.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

$ sudo systemctl reload [application]

A

Reload the application’s configuration files without restaring, if the application is able.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

$ sudo systemctl reload-or-restart [application]

A

If unsure about the service, try to reload it first. if not possible, restart it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

$ sudo systemctl enable [application]

A

Start the service automatically at boot. This will create a symlink from the system’ s copy of the service file (/lib/systemd/system or /etc/systemd/system)) into the location on disk where systemd looks for autostart files (/etc/systemd/system/some_target.target.wants).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

$ sudo systemctl disable [application]

A

Disable a service from starting automatically at boot by removing its symlink.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

$ systemctl status [application]

A

Check the status of a service: state, cgroup hierarchy, first few log lines.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the important directories and files for nginx?

A

/var/www/html/: actual web content. This can be changed by altering Nginx configuration files. /etc/nginx/: Nginx directory for configuration files. /etc/nginx/nginx.conf: global Nginx configuration file. /etc/nginx/sites-available/: directory where per-site “server blocks” can be stored. Nginx will not use the configuration files found here unless they are linked to the sites-enabled directory. /etc/nginx/sites-enabled/: directory where enabled per-site “server-blocks” are stored. /etcnginx/snippets/: this directory contains potentially repeatable configuration fragments that can be included elsewhere. /var/log/nginx/access.log: every request to the web server is recorded here unless asked otherwise. /var/log/nginx/error.log: any Nginx errors will be recorded here.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the purpose of a host file, such as /etc/hosts?

A

It has the function to translate human-friendly hostnames into numeric protocol addresses called IP addresses, which uniquely identify and locate a host in an IP network. It can be used to personalized the hostname of the corresponding IP addresses.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to associate a domain to an Ip address in a host file?

A

Example: 127.0.0.1 mydomain (for IPv4) ::1 mydomain (for IPv6)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

$ sudo tail -f /var/log/nginx/access.log

A

Display the most recent logs of Nginx as they are appended.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

$ sudo ufw app list

A

List the application configirations that ufw knows how to work with.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is a server?

A

A computer connected to a network (intranet or extranet), offering a service. The principal differences with a personal computer is that:

  1. It offers services.
  2. There is no GUI.
  3. It is always turned on.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is OpenSSH?

A

OpenSSH is a suite of security-related network-level utilities based on the Secure Shell (SSH) protocol, which help to secure network communications via the encryption of network traffic over multiple authentication methods and by providing secure tunneling capabilities.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Install OpenSSH (client-side, NOT server-side).

A

sudo apt-get install openssh-client

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

$ ssh-keygen -t rsa

A

Generate two SSH keys:

  • Public: ~/.ssh/id_rsa.pub
  • Private: ~/.ssh/id_rsa

Possibility to add a passphrase as an additional security to encrypt the private key.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How to authorize a connection from local host to the remote host / server?

A

The public key from local host should be copied to the remote host and its path appended to the ~/.ssh/authorized_keys file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Get the public keys of any GitHub user.

A

$ curl https://github.com/.keys

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

For what is the tar command line tool used?

A

To get together several files into one large file called archive.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What is the difference between gzip, bzip2 and zip, rar?

A
  • With gzip and bzip2, to compress several files into one archive, the user has to assemble the files together first (e.g. with tar) and then compress the archive.
  • With zip and rar, the previous two-step process is done in one step.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

How to use tar to create an archive?

A
  1. Get all files together under one directory ==> mkdir & mv
  2. Create a tar archive: $ tar -cvf [name].tar [directory]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

What are common options for the tar command-line tool?

A
  • -c: create an archive tar.
  • -v: display operations details.
  • -f: assemble the archive in a file.
  • -t: list the files in ar archive.
  • -r: append a file to an archive.
  • -x: extract.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

Display the content of an archive with tar without extracting it.

A

$ tar -tf [tar_file]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

Add a file to an archive already created.

A

$ tar -rvf [tar_file] [file]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

Extract the files of an archive.

A

$ tar -xvf [tar_file]

31
Q

What is the difference between gzip and bzip2?

A
  • gzip is more popular and faster than bzip2.
  • bzip2 is less popular and compresses better than gzip.
32
Q

Archive and compress files in the same command with tar and gzip or bzip2.

A
  • gzip: $ tar -zcvf [tar.gz_file] [directory]
  • bzip2: $ tar -jcvf [tar.bz2_file] [directory]
33
Q

Extract and uncompress files in the same command with tar and gzip or bzip2.

A
  • gzip: $ tar -zxvf [tar.gz_file] [directory]
  • bzip2: $ tar -jxvf [tar.bz2_file] [directory]
34
Q

Compress and uncompress with gzip or bzip2.

A
  • gzip:
    • $ gzip [tar_file]
    • $ gunzip [tar.gz_file]
  • bzip2:
    • $ bzip2 [tar_file]
    • $ bunzip2 [tar.bz2_file]
35
Q

Display the content of a single compressed file.

A

$ zcat (/zmore/zless) [compressed_file]

36
Q

Compress, view or uncompress .zip files.

A
  • Compress: $ zip -r [zip_file] [directory]
  • View: $ unzip -l [zip_file]
  • Uncompress: $ unzip [zip_file]
37
Q

Compress, view and uncompress .rar files.

A
  • Compress: only possible via a proprietary software.
  • View: $ unrar -l [rar_file]
  • Uncompress: $ unrar [rar_file]
38
Q

What are the two encryption methods used by the SSH protocols?

A
  1. Symmetric encryption:
    • A single key to encrypt and decrypt.
    • Con: all parties must know the key beforehand.
  2. Asymmetric encryption:
    • A public key to encrypt and a private key to decrypt.
    • The public key can be safely transmitted over a clear network. The private key must be kept secret.
    • Asymmetric encryption is much slower (x100-1000) than symmetric encryption.
39
Q

What is the secure SSH tunnel?

A
  1. First send the secret key for symmetric encryption via unsymmetric encryption (only during first exchange).
  2. Then always use this symmetric encryption key for the rest of the exchanges.
40
Q

Transform own personal computer into a server with ssh protocol.

A
  1. $ sudo apt-get install openssh-server (public and private keys are automatically created).
  2. $ sudo /etc/init.d/ssh start (start the server)
  3. $ sudo /etc/init.d/ssh stop (stop the server)
41
Q

Get our own computer’s public and local IPv4 (and IPv6) addresses?

A
  • Public: https://www.whatismyip.com/
  • Possibility to also local address with $ ifconfig
42
Q

Connect via SSH from a Linux machine.

A
  • If using default port 22: $ ssh [username]@[IP/hostname]
  • If using another port: $ ssh [username]@[IP/hostname] -p [port_number]
  • Afterwards, you will be given a password promt if password authentication is setup, otherwise public/private key authentication is used. If successful, you will get the server fingerprint.
43
Q

What is a server fingerprint? What is it used for?

A

Unique number identifying the server. Used to detect machines that would like to imitate a server (but with a different fingerprint).

44
Q

What is the ~/.ssh/knwon_hosts file?

A

List of fingerprints known to your computer. It used to remember the identity of servers and detect frauders.

45
Q

What are the two authentications methods used to connect to a server?

A
  1. Authentication via password.
  2. Authentication via public and private keys of he client.
46
Q

Send the public key to a server.

A
  • $ ssh-copy-id -i id_rsa.pub [username]@[IP/hostname]
  • May add a specific port with $ … -p [port_number].
  • The account password will be asked (NOT the private key passphrase).
  • The public key is automatically added to ~/.ssh/authorized_keys
47
Q

Why launch the ssh agent ssh-add?

A

So that you do not have to enter the private key passphrase each time you connect to a server. The ssh agent remebers the private keys during your session.

48
Q

Download a file with wget.

A

$ wget [HTTP_or_FTP_address]

49
Q

Continue a stop download with wget.

A

$ wget -c [HTTP_or_FTP_address]

Note: the partial file should still be on disk.

50
Q

Download a file in background task with wget.

A

$ wget –background [HTTP_or_FTP_address]

51
Q

Securely copy (scp) a file from one computer to another.

A
  • $ scp [origin] [destination]
  • If a specific port is required: $ scp -P [port_number] [origin] [destination]
  • Each of [origin] or [destination] can be written under the form [username]@[hostname]:[file_path]
  • If no username or IP are given, scp will think the file is on your computer.
52
Q

What is FTP?

A
  • FTP (File Transfer Protocol) is a protocol used to exchange files on a network.
  • Used in two cases:
    • Public FTP server with anonymous mode e.g. when you click on a download link.
    • Private FTP server with autenticated mode.
  • Can be done via command line or GUI software (e,g, FileZilla).
53
Q

Connect to a FTP server.

A
  • $ ftp [FTP_address]
  • A login will be asked. If publicserver : name is “anonymous” and password can be anything.
  • Secure FTP: $ sftp [username]@[hostname]
54
Q

Transfer files when connected via FTP.

A
  • $ put [local_file]: send a file to the server. Not possible with a public server.
  • $ get [remote_file] : download a file from the server.
55
Q

Execute command on local host when connect to remote host via FTP.

A

Put “!” in front of every command e.g. $ !cd

56
Q

What is rsync?

A

rsync is a command line tool used to synchronize two directories, whether they are or not on the same machine. Mostly used for incremental backups by only copying changes from the previous state.

57
Q

Create a backup copy with rsync on the same computer. List possible options for the backup.

A
  • On the same computer: $ rsync -arv [directory] [backup]
    • -a: keep all information about files, such as access rights, dates…
    • -r: backup sub-diectories.
    • -v: display information on the copy.
  • To delete files in backup as well: $ rsync -arv –delete [directory] [backup]
  • To create a backup for deleted files: $ rsync -arv –delete –backup –backup_dir=[absolute_backup_delete] [directory] [backup]
  • Possibility to exclude directories from backup.
58
Q

Create a backup on a different machine with rsync.

A
  • $ rsync -arv [origin] [destination]
  • If specific port: $ rsync -arv [origin] [destination] -e “ssh -p [port_number]”
  • [destination] has the form [username]@[hostname]:[path]
59
Q

Change the passphrase of your private SSH key, knowing the original passphrase.

A

$ ssh-keygen -p

60
Q

Display a SSH key fingerprint.

A
  • $ ssh keygen -l
  • You get: bit-length of key, fingerprint, account and host it was created for, algorithm used.
61
Q

How to avoid to enter SSH login each time we connect to a server?

A
  1. $ vim ~/.ssh/config
  2. Write in the following format:

Host [remote_alias]

HostName [remote_host]

Port [port_number]

62
Q

Two-way conversion of either hostname or IP address.

A

$ host [hostname] or $ host [IP_address]

63
Q

Know everything about a domain name (owner name, address, contact…).

A

$ whois [hostname]

64
Q

List a computer’s network interfaces.

A
  • $ ifconfig
    • eth0/1/2… : connection via cable
    • lo: local loop ==> everything is sent back to the computer.
    • wlan0/1/2… : wireless connection.
65
Q

Activate or deactivate a computer’s network interface.

A
  • $ ifconfig [interface] [switch]
    • [interface] can be eth0, lo, wlan0…
    • [switch] can be either up or down.
66
Q

Get information about the open connections of a computer. What are the various options?

A
  • $ netstat [options]
  • Options can be:
    • -u: display UDP connections.
    • -t: display TCP connections.
    • -a: display all connections no matter their state.
    • -n: display IP addresses and port numbers instead of hostnames.
    • -l: display (filter) connections with LISTEN state.
    • -s: display network statistics.
67
Q

What are the common states of the connections displayed by netstats?

A
  • ESTABLISHED: connection was established with a remote computer.
  • TIME_WAIT: connection is waiting processing of packets still on the network before closing.
  • CLOSE_WAIT: the remote computer has closed the connection itself (timeout?).
  • CLOSED: the connection is not used.
  • CLOSING: connection is closing but all data were not yet sent.
  • LISTEN: listening to coming connections.
68
Q

What is ufw?

A

ufw provides a user friendly way to configure the iptables firewall.

69
Q

What is iptables?

A

Default firewall on Linux. Possibility to filter IP addresses, which ports can connect to your computer, and which ports your computer can connect to. In general the technique is to block all ports than allow a few.

70
Q

List all rules of the iptables firewall.

A
  • $ iptables -L
    • Chain INPUT: incoming traffic.
    • Chain FORWARD: redirection of traffic.
    • Chain OUTPUT: outgoing traffic.
71
Q

Reset iptables traffic rules.

A

$ iptables -F

72
Q

What does a iptables rule looks like?

A
  • target: usually ACCEPT, otherwise DROP.
  • prot: the protocol used, like tcp, udp, icmp (ping requests).
  • source: source IP. For INPUT, it is the remote computer connecting to you.
  • destination: destination IP. For OUTPUT, is the the remote computer you are connecting to.
  • Last column (no name): display port in letters after “:”. Display numeric port with -n option.
73
Q

What are the two general network policies of iptables for each type of rule?

A
  • policy ACCEPT: all connections accepted except those defined by DROP rules.
  • policy DROP: all connections ignored except those defined by ACCEPT rules.