Group 08
Group 08
Example Commands:
1. Generate a Key Pair:
As part of our practical exercise on using GPG, we followed these steps to generate a key
pair:
1. Key Type Selection:
We started by selecting the type of key to generate. We chose the default option, "RSA
and RSA," which allows the creation of a key pair for encryption and signing.
2. Key Size Specification:
Next, we were prompted to specify the size of the RSA key. We entered 1024 as the key
size, which is within the supported range of 1024 to 4096 bits. This key size was selected
for demonstration purposes, though larger sizes provide stronger security.
3. Key Expiration Setting:
We then specified how long the key should remain valid. To ensure the key remains
usable indefinitely, we entered 0 for no expiration.
4. User Identification:
We provided the following details to create a unique User ID for the key:
• Name: Amani
• Email: [email protected]
• Comment: Amani RSA Keys
This information was displayed to confirm the User ID before proceeding.
5. Entropy Generation:
Finally, the system required the generation of random data (entropy) to create the key
securely. We followed the instructions to perform actions such as moving the mouse and
typing on the keyboard, which helped the system gather sufficient randomness for
cryptographic strength.
This process successfully generated a GPG key pair, which can now be used for secure
communication and data protection.
2. Export Public Key
We can share our public key so others can encrypt messages for us using the command:
4. Encrypt a File
We encrypt a file using the recipient’s public key with: This will create a message.txt.gpg.
5. Decrypt a File
To decrypt the file using our private key, we run:
6. Sign a File
We can create a digital signature for a file using:
7. Verify a Signature
To verify a file’s signature, we use the command:
SELinux (Security-Enhanced Linux)
SELinux is a Linux kernel security module that enforces mandatory access controls
(MAC). It defines access policies for processes and files, restricting unauthorized actions
even if an attacker gains root privileges.
How SELinux Works:
1. Modes:
o Enforcing: SELinux policies are enforced.
o Permissive: SELinux logs policy violations but doesn't enforce them.
o Disabled: SELinux is turned off.
2. Contexts: Every file, process, and resource has an SELinux context defining its role.
Example Commands:
b. Check status
d. Verify Status
2. List SELinux Contexts
To see the SELinux context associated with a file or directory, use the ll -Z command:
Explanation:
• User: unconfined_u — The user is unconfined (not restricted by SELinux).
• Role: object_r — The object role is used to label files.
• Type: xdg_documents_t — The file has the type xdg_documents_t, which is typically
assigned to user document files.
• Level: s0 — This is the security level, which in this case is s0 (the default level).
Now the file has the context httpd_sys_content_t, indicating it is treated as web server content
The file has now returned to its original SELinux context xdg_documents_t
5. View SELinux File Contexts on the System:
To list all the SELinux file contexts on your system, you can use the semanage command:
This will display the file contexts assigned to various system directories and files. For
example:
Summary:
• Checking Context: ll -Z file.txt shows the SELinux context.
• Changing Context: chcon -t <new_type> file.txt changes the file's context.
• Restoring Default Context: restorecon -v file.txt restores the file's default context.
• Viewing File Contexts: semanage fcontext -l lists the contexts for system files.
• Adding New Policies: semanage fcontext -a adds a new policy for a directory.
These practical examples show how to interact with SELinux and manage file contexts.