Changes

Jump to: navigation, search

OPS335 Lab 7 2018

7,460 bytes removed, 01:10, 1 April 2019
INVESTIGATION 2: CLIENT CONFIGURATION
[[Category:OPS335]][[Category:OPS335 Labs]]
== OBJECTIVE & PREPARATION==
==OBJECTIVE & PREPARATION== {{Admon* Download and run the [http://important|Prerequistites|This lab depends matrix.senecac.on changes made in several previous labs. You must have successfully completed labs 3, 4a, 4b, and 5 in order to be able to do this labca/~peter.callaghan/files/OPS335/nfs.}} Below is the same diagram that we referred to over the previous 2 email labs: [[Image:Email-serversbash nfs.pngbash]] Note the two globes in the above diagram. Those globes represent the Internet that script on each of your emails travel through in order to be received by an e-mail recipientmachines. The '''smaller globe (the one This will make your workstation is connected to) cannot be trusted to send mail messages unencrypted'''. The host'''larger globe usually involves inter-ISP traffic, often through an internet trunk line, so it is nfs server sharing the home directories held there with the vms. It will also unencrypted, but it cannot be easily accessed by hackers, pen-testers, or evildoers'''. There are '''two important general truths you need make the vms automatically try to understand about email encryptionmount the home directories held on ''': :* host'''Email (into their own filesystem as soon as they boot. reboot the way the vast majority of people use it) travels from SMTP server to SMTP server uncencrypted'''VMs now and make sure this is working before continuing:: That means that nothing sent over email * An NIS server is <u>truly</u> secure. But attempting to continually intercept SMTP server used to SMTP server traffic is difficult synchronize system files and expensive, not worth doing for the little bit of money most of us have other information between machines in our bank accountan NIS domain:* In this lab you will set your '''Email travelling over a LAN (especially Wifi, but any local network) is always encryptedhost'''. :: If e-mail traffic on a LAN was not encrypted, it would be easy as an NIS server and inexpensive to intercept share user information (in order to obtain your username names, groups, and passwordpasswords)with your VM's. These days, unencrypted connections from {{Admon/important|Prerequisites|Before you begin make sure all your client machines are up to your SMTP/IMAP/POP3 server very rarely existdateYou see in our diagram that one of the SMTP connections is supposed to be encrypted (this is the one that would be "LAN" traffic) Ensure both host and the IMAP connection as well (this one is either LAN-like traffic or is connecting to localhost, which is a different scenario altogether). WeVM're going s have firewalls set up according to secure the two connections that we left to be in plain text previously. Unfortunately encrypting things is rarely a straighforward process. Fortunately we prior labs and all labs have a whole week to spend on itbeen completed.}}
=== Online Resources===
* [https://en.wikipedia.org/wiki/Transport_Layer_Security TSL, SSL Definition]
* [https://www.e-rave.nl/create-a-self-signed-ssl-key-for-postfix Create a self signed SSL key for Postfix]
* [http://wiki2.dovecot.org/SSL/DovecotConfiguration Dovecot SSL configuration]
 
 
== INVESTIGATION 1: GENERATING A SELF-SIGNED CERTIFICATE ==
 
According to Wikipedia (https://en.wikipedia.org/wiki/Transport_Layer_Security), '''Transport Layer Security''' (TLS) and its predecessor, '''Secure Sockets Layer''' (SSL), both of which are frequently referred to as 'SSL', are cryptographic protocols designed to provide communications security over a computer network.
 
Normally (in production), you would need to pay a "certificate authority" to issue a '''certificate''' for you. That is essentially '''a "signed" public key''' that will tell strangers on the internet that your server is really yours (i.e. the certificate authority says so). There is an obvious problem with the previous statement but that is mainly how public key encryption works on the Internet today.
We will be generating our own public keys, mainly in order to avoid paying for a certificate== INVESTIGATION 1: SETTING UP YOUR NIS SERVER ==*Install the NIS server and client onto your host. We will not have enough time yum install ypserv ypbind*Add the following line to get into the details bottom of what all the following commands do in this sectionfile /etc/sysconfig/network NISDOMAIN="<seneca-id>. They are from ops" YPSERV_ARGS="-p 783"*This should be enough to set the domain name, however there is currently a [https://www.ecentos.org/forums/viewtopic.php?t=47013 bug] in systemd that prevents this from working properly on its own.**You will also need to start and enable the rhel-ravedomainname service.nl*Edit the file /etc/create-a-self-signed-ssl-keyyp.conf and set up your domain: domain <seneca-id>.ops server 127.0.0.1*Create the file /var/yp/securenets: host 127.0.0.1 255.255.255.0 192.168.x.0*Enable and start the NIS (ypserv) service. systemctl start ypserv.service systemctl enable ypserv.service*Backup the configuration file forNIS databases cp /var/yp/Makefile /var/yp/Makefile.orig* Verify that your servers (NFS, ypserv) are running correctly with the following command: rpcinfo -postfix p*At this blog post]step you should edit your firewalls to allow RPC and NIS traffic through your firewall (Hint: check the output of rpcinfo -p or iptables traffic on the "lo" interface), but only if the traffic came from inside your virtual network. *The machine will essentially be communicating with its own NIS server when using the Makefile*Now change to directory /var/yp and run this command to build the information databases make ('''NOTE: '''If you donreceive a "Domain name cannot be (none)" message, restart 't understand what 'rhel-domainname'' and try again.)*Enable and start the NIS binding (ypbind) service. systemctl start ypbind.service*Use the blog post refers following command to but would like verify your NIS server is working - you should see the password record for your own user account. ypcat passwd*Add a new user to understand your '''host''' with the same name as the one you created on '''vm3''' in more detailslab 4b, but use a good recommended book different password.*Run 'ypcat passwd' again.*Note that the new user does not appear. In order for interest, called Crypto by Steven Levy, provides a more inthe new user to show up you will need to recreate the map files-depth discussion of encryption change directory to /var/yp and securityrun the "make" command again.
The public key cryptography concepts in this lab are the same in a previous lab ([http== INVESTIGATION 2://zenit.senecac.on.ca/wiki/index.php/OPS335_Lab_1#SSH_Keys Lab1: SSH]), although the terminology is slightly different.CLIENT CONFIGURATION ==
A simple way *Log into '''vm3''' as the new user. Note how they require different passwords on different machines.*Log out, and log back in as '''root''' (or use your normal user and '''su''') to continue.*Install ypbind on your vm3.* You may wish to follow the logs on vm3. In addition to summarize your normal log in, ssh from the differences ishost to vm3 and get a continuous feed from the logs with: tail -f /var/log/messages*Edit /etc/yp.conf adding the following line: domain <senecaid>.ops server 192.168.x.1* The Start the ypbind server with the command. systemctl start ypbind.service ('''.keyNOTE: ''' If you receive an error about rpcbind, ensure "NM_CONTROLLED=no" is removed from your ifcfg file and restart that interface.)*Looking at your logs ensure that ypbind is registered with rpcbind, if it is unable your private keyfirewall may need to be adjusted.*Now when you run the following command: ypcat passwd*You should be able to see the users from the server.*If you added a mismatched user, you must update the map files on the server by running make again.*Edit the /etc/nsswitch.conf file (on the VM only) and change the following lines so they appear as below: passwd: nis files shadow: nis files group: nis files*Save and exit the file.*Ensure ypbind will start at boot and restart the vm.*Note that a recent bug is making machines with ypbind running take extraodinarily long to shut down.*Log into vm3 as the new user. You should now be able to use the password stored on '''host'''.* The Back on '''host''' change the password for the new user and rebuild the maps.crt Try to log into ''' file is your public keyvm3''' with the old password; it should now require the changed password.
== INVESTIGATION 3: ADDING THE OTHER VMS ==
*When you have successfully made this change on '''vm3''', repeat these steps so that '''vm1''' and '''vm2''' will also use NIS for user identification from files located on '''host'''.
**Warning: When configuring the location of the NIS server to bind to, use the ip address instead of the hostname. When the machine is booting, you have no guarantee that '''named''' starts before '''ypbind'''.
=== Encrypting Postfix with Transport Layer Security (TLS) ==={{Admon/important |Backup your VMs!|You MUST perform a '''full backup''' of ALL of your VMs whenever you complete your '''OPS335 labs''' or when working on your '''OPS335 assignments'''. You should be using the dump command, and you should use the Bash shell script that you were adviced to create in order to backup all of your VMs.}}
'''Perform the following steps:''' #Let's start with the "sending" SMTP server we have on VM2. Run the following, replacing <u>andrewsmith.org</u> with '''<u>your</u> domain name''': <source lang="bash">mkdir -p /root/postfix-keys /etc/ssl/{private,certs}cd /root/postfix-keysopenssl genrsa -des3 -out vm2.andrewsmith.org.key 2048chmod 600 vm2.andrewsmith.org.keyopenssl req -new -key vm2.andrewsmith.org.key -out vm2.andrewsmith.org.csropenssl x509 -req -days 365 -in vm2.andrewsmith.org.csr -signkey vm2.andrewsmith.org.key -out vm2.andrewsmith.org.crtopenssl rsa -in vm2.andrewsmith.org.key -out vm2.andrewsmith.org.key.nopassmv vm2.andrewsmith.org.key.nopass vm2.andrewsmith.org.keyopenssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650chmod 600 vm2.andrewsmith.org.key cakey.pemcp vm2.andrewsmith.org.key cakey.pem /etc/ssl/privatecp vm2.andrewsmith.org.crt cacert.pem /etc/ssl/certs</source> ::'''NOTE:''' Those commands will create a certificate, a certificate signing request, a certificate authority, and sign your certificate with your certificate authority.<br>This would be the same as in the real world except there you would contact a real CA, here you're making up your own. <ol><li value="2">Now, configure Postfix to use the generated certificate, by adding Completing the following to your '''main.cf''' file:</li></ol> <pre># Settings to enable secure SMTP using my self-signed certificate:smtpd_tls_auth_only = nosmtpd_use_tls = yessmtp_use_tls = yessmtpd_tls_key_file = /etc/ssl/private/vm2.andrewsmith.org.keysmtpd_tls_cert_file = /etc/ssl/certs/vm2.andrewsmith.org.crtsmtpd_tls_CAfile Lab= /etc/ssl/certs/cacert.pemtls_random_source = dev:/dev/urandomsmtpd_tls_loglevel = 1</pre> === Setting Up and Testing Encryption with Thunderbird === '''Perform the following steps:''' #Currently your Thunderbird is set up to use '''vm2.yoursenecaid.org''' for an SMTP server, with <u>no</u> security. Change that to use '''STARTTLS''' instead (you can change it under '''account settings --> Outgoing Server''').# We haven't set up any user authentication, just an encrypted channel;therefore, leave the '''authentication method''' at the value: '''none'''.#When you try to send an email Thunderbird will warn you about the self-signed certificate. You obviously know it's your certificate so you can tell Thunderbird to trust it:  [[Image:SMTP-certificate-warning.png]]  ::'''NOTE:''' Your message may look slightly different (This author, that have now created the diagram above, made a little mistake when generating the certificate). <ol><li value="4">After you confirm that security exception, send another email to yourself and make sure you receive it.</li><li> Notice that from the user's point of view nothing is different. But if you were an evildoer trying to steal an identity (the difference is huge). Before it was trivial and now it's computationally prohibitive.</li></ol> === Encryption Dovecot with Secure Socket layer (SSL) === Now we will ensure that our '''Dovecot''' connection is secure, and enforce that policy. With SMTP, you will need to allow plain text connections since that is the only method to pass email from server-to-server. With IMAP, there is no server-to-server interaction, but rather only client-to-server interaction. The reason to have an unencrypted IMAP connection would be if your '''IMAP NIS server''' and '''IMAP client''' were the <u>same</u> machine. '''Perform the following steps:''' # Let's start by generating a new certificate for Dovecot on your vm3 machine by issuing the following commands:<source lang="bash">mkdir /etc/ssl/{private,certs}openssl genrsa -des3 -out vm3.andrewsmith.org.key 2048chmod 600 vm3.andrewsmith.org.keyopenssl req -new -key vm3.andrewsmith.org.key -out vm3.andrewsmith.org.csropenssl x509 -req -days 365 -in vm3.andrewsmith.org.csr -signkey vm3.andrewsmith.org.key -out vm3.andrewsmith.org.crtopenssl rsa -in vm3.andrewsmith.org.key -out vm3.andrewsmith.org.key.nopassmv vm3.andrewsmith.org.key.nopass vm3.andrewsmith.org.keyopenssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650chmod 600 vm3.andrewsmith.org.key cakey.pemcp vm3.andrewsmith.org.key cakey.pem /etc/ssl/privatecp vm3.andrewsmith.org.crt cacert.pem /etc/ssl/certs</source> ::'''NOTE:''' This process is identical to what you've done for the vm2 certificate. In fact if your IMAP and SMTP servers are on the same machine you can share the certificate between them. In our case, they are not on the same machine. <ol><li value="2">Next, we need to configure Dovecot to use this for encrypted connections and not allow any kind of plain text connections. Edit the '''10-auth.conf''', <u>and</u> '''10-ssl.conf''' files and change the following settings (note: these parameters already exist in those files, just find them and set them to the correct value):</li></ol> <source lang="bash">ssl = requiredssl_cert = <path_to_your_crt_filessl_key = <path_to_your_key_filedisable_plaintext_auth = yes</source>  <ol><li value="3">Now, we will disable normal imap connections, leaving only imaps (secured imap) allowed. Edit the '''10-master.conf''' file and set the port number in '''inet_listener imap''' to '''0'''.</li><li>Your key/certificate doesn't have a '''.pem''' extension but they are PEM-encoded files. You can confirm that using the '''file''' command. If you're interested, learning more about configuring Dovecot for SSL, refer to the following documentation: [http://wiki2.dovecot.org/SSL/DovecotConfiguration Dovecot SSL configuration].</li></ol> === Verifying that Mail Messages are Encrypted=== '''Perform the following steps:''' #Use the '''ss''' command to confirm you're only listening on the '''imaps''' port, network and not the plain imap port.#Next, reconfigure caused your account settings in Thunderbird other virtual machines to use the '''SSL/TLS''' connection security with your IMAP server, leaving the password it as '''Normal Password'''. ::'''NOTE:''' When you send your test email, you will get another warning because you're using a self-signed certificate on '''vm3'''. Make certain to authorize the exception. '''Record steps, commands, and your observations on this investigation in your OPS335 lab log-book''' == INVESTIGATION 2: INSTALL, CONFIGURE &amp; RUN WEBMAIL APPLICATION (Roundcube Mail) =={|cellpadding="15" width="40%" align="right" |- valign="top" |width="10%" | [[Image:Roundcube.png|thumb|right|200px|'''Roundcube''' webmail application Logo<br>GPL,<br> https://commons.wikimedia.org/w/index.php?curid=1772791]] |width="10%" |[[Image:roundcube-pic.png|thumb|right|300px|Screencapture of '''roundcube''' webmail application running in order to send and receive mail messages via a web-browser.]]  |} In the investigation, we will simply install, configure and run the '''roundcube''' webmail application. '''Perform the following steps:''' #Perform a search on the roundcube application in order to access the website.#Either Download the "zipped tarball" from their website from a direct link or use the wget command to download directly from a download link (This part may take some effort depending on the Sourceforge website).#Extract the "zipped tarball" and rename the generated directory that contains download source code to: '''webmail'''.#In the directory now named "webmail", there will be a file named '''INSTALL''' which will walk you through the rest of the Roundcube installation.<br><br>Some installation tips to consider: ::* Be careful about copying &amp; pasting the MySQL setup part: take time and pay attention to detail: do not try to "rush it".::* You will need to install several additional Apache modules including: '''php-xml''', '''php-pdo''', and '''php-mysql'''.::* Don't forget to set the password in the roundcube configuration. <ol><li value="3">Note that both of your IMAP and SMTP servers are on different machines (i.e. not on vm1). Therefore, you will need to set the following options central repository for Roundcube:</li></ol> ::* '''$config['smtp_server']'''::* '''$config['default_host']'''::* '''$config['default_port']''' :::'''NOTE:''' The last <u>two</u> entries above refer to your IMAP server <ol><li value="4">You should be able to test the configuration in your Roundcube installer after completing Step 3.</li><li>Try to test if the roundcube webmail application is working by sending and receiving e-mail messages.</li></ol> '''Record steps, commands, and your observations on this investigation in your OPS335 lab log-book''' ==COMPLETING THE LAB==In completing this lab you have gained experience..user information.
'''Depending on your professor you will either be asked to submit the lab in class, or online. Follow the appropriate set of instructions below.'''
===Online Submission(Peter Callaghan's Classes only)===Follow the instructions for lab 8 7 on moodleblackboard===In Class Submission==='''Arrange evidence (command output) for each of these items on your screen, then ask your instructor to review them and sign off on the lab's completion:''' ::<span style="color:green;font-size:1.5em;">&#x2713;</span>Thunderbird with a message sent and received using encrypted channels.::<span style="color:green;font-size:1.5em;">&#x2713;</span>New Thunderbird server configuration for your account.::<span style="color:green;font-size:1.5em;">&#x2713;</span>Logs on vm2 and vm3 showing the message has been sent and received.::<span style="color:green;font-size:1.5em;">&#x2713;</span>Your webmail showing your inbox::<span style="color:green;font-size:1.5em;">&#x2713;</span>Your webmail sending an email out::<span style="color:green;font-size:1.5em;">&#x2713;</span>You receiving that mail on an exernal account 
==EXPLORATION QUESTIONS=In Class Submission (Murray Saul's Classes only)===::<span style="color:green;font-size:1.5em;">&#x2713;</span>Download the labcheck7.bash checking bash shell script by issuing the command:<br><br>'''wget http://matrix.senecac.on.ca/~peter.callaghan/files/OPS335/labcheck7.bash'''<br><br>set execute permission and run the shell script on your '''host''' machine. ::*For '''Peter's classes''', follow his Online Submission instructions in Moodle.::*For '''Murray's classes''', run command (piping to the '''more''' command) and show output to instructor.::<span style="color:green;font-size:1.5em;">&#x2713;</span>Completed Lab7 log-book notes.
== EXPLORATION QUESTIONS ==#Briefly define What is the term '''TSL'''.purpose of the rpcinfo command?#Briefly define Explain the term '''SSL'''.#List purpose of the steps to setup Encryption for Postfix with TLS.#List make command in the steps to setup Encryption for Dovecot with SSL.lab - what does it do?#List Explain the steps to setup Encryption for purpose of the Thunderbird application/var/yp/securenets file.#Provide a brief description What is the function of the following terms as they relate to mail servers:#*'''Open Relay'''#*'''SPF'''#*'''DKIM'''# How does a webmail application differ from using another MUA like Thunderbirdportmapper service?# List the additional Apache modules that are required in order What ports did you need to run the Roundcube web applicationopen on your firewall?

Navigation menu