martes, 6 de enero de 2015

Setup Email Server - Part 2

Hello, in this blog we will continue the email server installation/setup.

In our previous post we instructed about the assets we purchased from GoDaddy and DNS configuration to resolve to our server.

In this post we will install the SSL certificates in our server so we can use them to encrypt and secure our https and email traffic.
To accomplish this you will need:

  • OpenSSL software to generate private key and certificate signing request (CSR)
  • SSL certificate available to be Set Up in GoDaddy
  • SCP software to transfer files through the ssh (like pscp)

Generating the private key and CSR using OpenSSL

Execute using the command line:

openssl req -out request.csr -new -newkey rsa:2048 -nodes -keyout private.key

You will be prompted to provide information that will be present in the certificate to authenticate you and your company as the issuer:

  • Country Name (2 letter code) [AU]: MX
  • State or Province Name (full name) [Some-State]: Chihuahua
  • Locality Name (eg, city) []: Ciudad Juarez
  • Organization Name (eg, company) [Internet Widgits Pty Ltd]: Inspiracode
  • Organizational Unit Name (eg, section) []: software development
  • Common Name (e.g. server FQDN or YOUR name) []: inspiracode.net
  • Email Address []: diego.torres@inspiracode.net

This process will generate 2 main files:

  • A private.key file: This file is like your password, please save it in a secure place and don't share it with anyone. You will have to transfer this file later to the server, so the server can be capable of negotiate SSL transactions.
  • A request.csr file: This file is your formal request for signing the certificate, you will share the contents of your Certificate Signing Request (CSR) with your Certification Authority (in my case, I will share this contents with GoDaddy).

In GoDaddy, we will request for signing the SSL certificate using the CSR file:

  1. Open "My Account" in GoDaddy and scroll down to the SSL Certificates section
  2. Expand the SSL Certificates section and you should see an available certificate for "Set Up", click the "Set Up" button
  3. You will see now a new certificate available in the SSL Certificates section, click the "Launch" button
  4. The Certificates section will open, click on "Set Up" for your SSL certificate
  5. Open the request.csr file with a notepad, copy the contents and paste them in the text area for CSR
  6. Read and agree the terms and conditions of the "Subscriber Agreement"
  7. Click the "Request Certificate" button

You will be redirected to the certificate evaluation results and if everything went good with your domain verification, you will be able to download the certificate. One of the questions that the verification process will do is: Does the domain belongs to you or anyone else? If it belongs to another person, that person will be asked for permission for the certificate to be generated.
When you download your certificate, you will receive a zip file containing 2 files:

  • A GoDaddy bundle certificate (gd_bundle-g2-g1.crt)
  • A certificate file named with the serial number of your certificate ([certserialnumber].crt)

Unzip the contents in your machine and let's transfer those certificate files to your server:

  1. Use the scp command to upload the certificate (the one named with the serial number) to your server.Basically, the scp command will work like this:
    $ scp [origin] [destination]

    [origin] and [destination] can be either a local file, in which case you will use a reference path to reach the file you are transfering like: "/path/to/file" or they can be remote locations. In the case of a remote location [origin] and [destination] will have these parts: user@server:/path/to/resource. In my case I'm transferring my certificate 2b6db4c267ac13.crt to the inspiracode server:

    $ scp 2b6db4c267ac13.crt user@inspiracode.net:/home/user/
    you will be prompted for certificate sharing for ssh session and password.
  2. Use the same method used to upload the private.key file

Now we have to Move the certificates files to a shared location so the apache server has access to them.

  1. Use an ssh tool to login to your server and create a directory to store your certificates, I'm creating the directory "/certs/":
    $ sudo mkdir /certs/
  2. copy the certificates to your just created directory:
    $ sudo cp ~/private.key /certs/private.pem
    $ sudo cp ~/2b6db4c267ac13.crt /certs/public.pem

Note that when I'm creating a copy of my certificate files I'm renaming them to private.pem and public.pem, this is just for a more clear reference in the following configurations.
In the next post we will install and configure postfix and dovecot, and we will also configure the SSL secure traffic for email and http content.

domingo, 4 de enero de 2015

Setup Email server - Part 1

Hi, in this post I will show you the steps to follow in order to install and setup an email server.

We are using the following components:

  • GoDaddy domain and SSL certificates.
  • GoDaddy virtual private server (VPS) hosting
  • Postfix MTA
  • Dovecot email server
  • smtp2go outbound smtp account for outgoing email

GoDaddy assets

We first purchased our domain name and SSL in goDaddy and we also purchased a VPS hosting. This will give you the following assets:

  • An IP address for your VPS. The VPS is a server that you can access by an SSH terminal and install whatever you like. In our case we will host web pages and email. Later, we will add web services and products information. Will keep you posted about it.
  • DNS configuration access: So the internet can resolve your VPS' IP address as your domain name.
  • SSL certificate that you can request using a Certificate Signing Request (CSR) and encrypt your server's traffic

Configure the DNS in goDaddy

For now we have the following assets from what we have purchased:

  • We can browse to our VPS server using an internet browser using the IP address:
    Navigate to your VPS ip
  • We can login to our VPS using SSH (Putty is the tool we are using here):
    ssh login
  • Domain is listed in our GoDaddy domains account:
    domain listed
  • We have an available certificate in GoDaddy SSL CERTIFICATES section.
    GoDaddy available SSL certificate.

To configure the domain name (inspiracode.net) to be resolved to the given IP address for the VPS server (192.169.235.218) we can use the following steps in GoDaddy.

  1. In the domains section select the Launch action from the domain that you want to configure (in our case it is inspiracode.net).
  2. Select the DNS Zone File tab.
  3. Add an A(Host) record to resolve to your server IP address. (in our case 192.169.235.218)

More advanced information about other configuration options can be found here.

As our certificate has been purchased to certify and encrypt inspiracode.net we have these options:

  1. We use the same domain name and IP address to serve all items that we would like to encrypt and secure.
  2. We purchase a different certificate for each different sub domain that we would like to secure (mail.inspiracode.net; smtp.inspiracode.net; ftp.inspiracode.net; etc.).
  3. We purchase a multiple domain certificate or wildcard certificate to encrypt all our different subdomains (*.inspiracode.net)

We have decided that for now, while we have some growth in our business we will use the option 1 and use the same domain name for the different services that we will allow in our server.

This decision affects the way we will create our DNS MX records.

Normally you will add MX records for your email server in a domain like mail.inspiracode.net or smtp.inspiracode.net. In our case we will add the MX records in the same inspiracode.net domain. To configure the mx records we can use the following steps in GoDaddy:

  1. In the domains section select the Launch action from the domain that you want to configure (in our case it is inspiracode.net).
  2. Select the DNS Zone File tab.
  3. Add an MX record to resolve to your server IP address. (in our case 192.169.235.218)

The result of doing this is that your DNS is configured to resolve your domain name (in our case inspiracode.net) to your VPS server (in our case 192.169.235.218).

Now, when navigating to http://inspiracode.net you will receive our Apache home page:

In the next post we will continue with:

keep tuned.

--D