Linux For System Administrators and Devops
Linux For System Administrators and Devops
Linux For System Administrators and Devops
2
Linux for system administrators and DevOps
1st edition
© 2015 Mostafa Abd-ElHamid Atwa & bookboon.com
ISBN 978-87-403-1137-2
3
LINUX for System Administrators and DevOps Contents
Contents
Disclaimer 7
Introduction 8
4
LINUX for System Administrators and DevOps Contents
2 Linux Infrastructure 29
2.1 Installing DNS, DHCP, and Kerberos 29
2.2 Managing Users and Groups 41
2.3 Installing and Managing Linux Firewalls 43
2.4 Installing and Managing Web Servers 46
2.5 Installing and Managing Mail Servers 49
2.6 Installing and Managing FTP, SFTP 55
2.7 Installing and Configuring SAMBA and Managing Shares 58
2.8 Installing GIT Server 60
3 Security in Linux 63
3.1 Installing SSH 63
3.2 Creating Certificates using SSL 64
3.3 Working with SELinux and Access Control 69
3.4 Connecting to Linux Machine 72
3.5 Securing your Web Server in Linux 74
3.6 Securing your Database Server in Linux 74
3.7 Securing your Linux Virtual Machine 75
Download now
5
LINUX for System Administrators and DevOps Contents
4 Networking in Linux 76
4.1 Wired Networking in Linux 76
4.2 Wireless Networking in Linux 78
4.3 Network Manager in Linux 79
4.4 Monitoring Your Network in Linux 80
4.5 Scanning Your Network in Linux 82
Download now
6
LINUX for System Administrators and DevOps Disclaimer
Disclaimer
The information in this document is based on publicly available documentation’s and author’s personal
& professional experience. In no event shall author be liable for any direct, indirect, consequential,
punitive, special or incidental damages (including, without limitation, damages for loss of profits, business
interruption or loss of information) arising out of the use or inability to use this document, even if Author
has been advised of the possibility of such damages. Author makes no representations or warranties
with respect to the accuracy or completeness of the contents of this document and reserves the right to
make changes to this document at any time without notice. Author does not make any commitment to
update the information contained in this document.
For Manon Niazi, the Deutchlander, I still like the college days as it was happening yesterday.
For my mother and family.
For the soul of my heavenly father.
7
LINUX for System Administrators and DevOps Introduction
Introduction
This book is dedicated for LINUX engineers, system administrators and devops who can use the materials
illustrated in this book in most of their daily tasks during work.
It can transform you from basic-novice LINUX related engineer or an engineer with no-experience in
LINUX environments to an experienced and advanced LINUX professional.
8
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
The LINUX operating system was intended for mainframe computers and large-scale server systems,
but now it is running on desktop machines, tablets, and smart phones.
1. Debian Based
2. Gentoo Based
3. Pacman Based
4. RPM-Based
5. Slackware Based
6. Independent
Most of the book material is dependent on LINUX DEBIAN UBUNTU and as the time of writing this
book on version 15.04.
Honestly I have choose this distribution because it is the most supportive and popular distribution and
flavor of all the LINUX operating system distributions and ranked number 1 across the LINUX family.
You can switch between desktops, browse folders, share files and do most of the basic regular usage on
it every day.
You can manipulate folders, files, create images, browse the Internet, etc.
9
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
You can also create a network of computers, share printers and files, you can create print servers, make
word processing, and you can operate the machine easily as you want to do any task during your working
day, and even at home, or on your phone, it can now manage your phone calls, and you can use it on
your tablet to create and send e-mails, browse the Internet and more…
It can also manage your storage devices, network devices, and any machine that is capable of being
connected to the computer infrastructure.
The focus of the study of this book is to do server-client infrastructure and management of LINUX
environment containing desktop, tablet, mobile and server machines.
10
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
Server Distribution Versions of LINUX are equipped with a terminal screen as the user interface screen
and mostly does not contain any graphical user interface for the sake of security and performance.
We will talk about what is the terminal screen in chapter VI customizing LINUX shell and you will gain
more information about the shell environment and basic shell commands.
You can take a look around you to get to notice what are the capabilities of servers and what can the
server do for you and your environment.
For example if you look at the mail services like your company mail service, your free service provider
that provide mail services for free over the Internet or for profit.
The mail server is used to save all the mail messages that you send, receive and you partially write
and save on a large storage media precisely allocated for mail messages, attachments, drafts etcetera
and specialized for the privacy of every user using user account authentication and authorization with
security mechanisms.
Another example of the server-client environment is when you use your drive account on any cloud
storage provider or you use a mapped network drive on your company’s environment, this is simply
a storage server with an FTP, SFTP protocols installed on a server machines and mapped to network
drives on your working machine.
11
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
This infrastructure contains regular PC computers, laptops, tablets, mobiles, printers, scanners, ISP
wireless device, modem, storage router software, storage tapes, cluster, workstation, etcetera.
Download now
12
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
The client here in this infrastructure is represented by the PC, laptop, scanner, printer, and tablet devices
and server is represented by the cluster, storage router, tapes, and workstation.
There are also network mediums that transfer data between devices like the wireless device in the middle
and the modem device at the bottom of the cluster.
The minimization of LINUX cloud images is for performance and disk occupation, which will also allow
the user to get rid of the idle features that do not fit the environment the user is intending the build
like for example if the user is building a web server environment, the user will have only to install the
features of the web server environment without the need to have all other LINUX features.
LINUX cloud images have a terminal user interface and does not include any graphical user interface in it.
LINUX cloud images are built on the same distribution flavors that we mentioned earlier in the section
named #What is LINUX?|outline
Cloud images are used to be deployed into virtual machines and you can also deploy complete LINUX
images on virtual machines.
You can use Cloud Images to deploy it on cloud operating systems like OpenStack® and AWS (Amazon
Web Services) EC2 (Elastic Compute Cloud) or other cloud provider companies.
Cloud images can be in 32bit and 64bit architectures based on the processor of the hardware you are
using, you can install the suitable cloud image on the suitable virtual machine you have assigned on
that hardware processor.
Cloud images for example can be downloaded from the following URLs:
https://cloud-images.ubuntu.com/
https://aws.amazon.com/marketplace/ref=mkt_ste_amis_redirect?b_k=291
These links are not permanent and if you found a change within these links, you can search for cloud
images over the Internet to download any of these images.
We will talk about virtual machines later in a topic called LINUX virtual machines.
13
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
And in other distributions it may vary a little bit than these commands but all of these commands are
performing system update.
It may also vary in the package name (program name) you are installing on different distributions like
for example:
Installing MySQL database server on fedora may differ than installing it on UBUNTU® as follows:
So the package name has changed from UBUNTU® repositories to FEDORA® repositories from mysql-
server in UBUNTU® to mysql-community-server in FEDORA®
And finally you need to be adopting your command to the distribution you are working on.
If you are installing a package (program), you need to know what is the exact package name of the
distribution you are working on or performing this command on or if you are performing operating
system optimization command, you also need to know each command on each distribution and execute
the command which is suitable for the distribution.
14
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
We can perform command on this terminal window, and as you can see it, it is much similar like a
minimal text editor for entering the installing and system manipulation commands.
This window can be customized according to the user needs like changing the background color and
text color.
15
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
This window also can run commands as administrator power by using “sudo” keyword or by switching
to the super user for the session you are currently working on by using the command sudo -s which
will transfer you to the sudo privilege of the root user and you will notice that you will be using
root@youroscomputername.
Figure 1.3 shows you how this command is performed on an UBUNTU distribution.
This way, you can perform all the commands using power user (sudoer) or administrator or root user.
And you will see the output of this command in figure 1.4
Figure 1.4 shows the update and upgrade process of UBUNTU LINUX distribution.
This command is used to completely update your LINUX distribution from using LINUX repositories
that is belonging to the country where you are using the distribution.
Notice that we use the “--fix-missing” key to switch to alternative packages in case of any failure,
and you can also use this key with other commands if possible.
16
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
If you want to use the main server repositories instead of country specific repositories, please run the
following command:
You need to go up and down using arrow keys on your keyboard to reach to the line that you want to edit.
Locate all the country area in each line in my file here it is “eg.” in every line and remove it completely.
Example “deb http://eg.archive.ubuntu.com/ubuntu/ vivid-updates main restricted” to “dev htp://archive.
ubuntu.com/ubuntu/ vivid-updates main restricted” and you are good to go.
After performing these changes to the file, press CTRL+X on your keyboard to close the file. Notice that
it is prompting you to save the file and choose the file name. You can just press Y on your keyboard and
hit enter to save to the same file name and same directory.
Continuing basic commands for your LINUX environment, we can also get to know other commands
which are very useful in every day system administration tasks.
To get all the running programs and processes on your LINUX distribution type the following command
in the terminal window:
ps aux | less
17
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
You can go to the next line by pressing ENTER key on your keyboard for every line, then you can exit
using the CTRL + Z to quit this command output screen and go back to the terminal original prompt.
Download now
18
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
One of the commands that also will be one of the most favorable is how to create a SWAP file used to
strengthen the computer performance and LINUX will use it as RAM as follows:
This command will make a SWAP file on the root directory of your LINUX distribution that will contain
4 portions [count=4] and will be divided into 4 partitions, every partition will be 1 Giga Byte [bs=1G].
This way, you have created the SWAP file and the next step is to use it and make it available for your
LINUX distribution (inform your LINUX distribution) to use it.
You need to adjust the privileges and ownership of the file that we have created by using the following
command:
This command does not have any output and it will return you to the prompt again without any text to
appear after executing this command. In this command we have used “chmod” which is short for change
mode of the file and we used 600 as an aliased number for assigning privileges to the file and make it
only available to the operating system authorized users who can manipulate this kind of file, then we
gave it the file path using /swapfile directive.
The output of the command is shown in figure 1.8 confirming that the command has been successfully
executed.
And this command does not show any output or text confirming the command success.
19
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
But we can confirm that the file has been successfully allocated by using this command:
Now the command output confirming that the file has been created successfully and working as required.
Continuing our basic commands section, we still can perform some terminal tasks that can be very
useful in everyday LINUX administrator tasks:
How to manage services on LINUX machine and how to kill a process that you do not need after listing
all the processes and identifying which process you need to kill will be covered in the following section.
By running this command you will be able to identify all the processes running on a LINUX machine
and will identify every process using the process id as follows:
sudo swapon -s
By running this command, you will get a list of the processes with the process id as PID and figure 1.9
shows the output of this commands
By identifying the process using the PID you can use the following command to terminate this process
20
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
As shown in figure 1.10, you need to replace the PID with the ID of the process you want to top, in my
case I have stopped mysqld using the PID 14846.
Finally you can use the following command to start, stop and restart any service that you want
This command does not give any output or text indicating success but in case of failure, you will be
notified with a notice indicating failure with reason according to the specific service you are managing.
In my case I have apache2 installed on my distribution and I have started, stopped, and restarted it in
these 3 commands.
The following section will be containing useful links on how to work with LINUX shell.
https://help.ubuntu.com/community/UsingTheTerminal
http://www.fedorafaq.org/basics/
Download now
21
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
In this section we need to be familiar with programming and how to use the LINUX shell to make a
shell script that is containing some tasks for the terminal to do.
First we need to identify what is a shell script file and how can we create one of these files, then list our
commands that does a specific task into this file, then run this file in a terminal window as follows:
1. touch helloworld.sh
2. nano helloworld.sh
3. echo “Hello World”
4. Press CTRL + X and then type y then hit enter key on your keyboard.
5. sh helloworld.sh
This will give the output Hello World in your screen on the terminal window.
What we did now is a kind of shell script file containing one single command that tells the computer to
output the sentence Hello World.
• First we created a file called helloworld.sh using the command touch helloworld.sh
• Second we edited the file using a program called nano using this command nano helloworld.sh
• Third we added one line into this file telling the computer to output a Hello World sentence to
the screen using the echo command in terminal by the use of this command echo “Hello World”.
• Fourth we saved the file using CTRL + X on your keyboard and confirming by typing Y,
then pressing enter to use the same file name and directory.
• Finally, we executed this script using sh command and pointing to the file name that we
created in the previous steps using this command sh helloworld.sh and gave us the output as
the following figure 1.11 shows us:
22
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
This way you have created a file into a shell script, entered a command in it and executed this command.
You can perform the previous steps with a list of commands under each other into this file after executing
the nano command and starting editing the shell script file.
1. touch iterationofdays.sh
2. nano iterationofdays.sh
3. i=1
4. weekdays=”Mon Tue Wed Thu Fri”
5. for day in $weekdays
6. do
7. echo “Weekday $day”
8. done
9. Press CTRL + X on your keyboard, follow it by Y, then press enter to exit.
10. sh iterationofdays.sh
In this example we did a series of commands that will be illustrated in the following points:
First: We created our shell script file using the touch command as we did in the previous example.
Third: We inserted the variable called i and gave it the default value of 1.
Fourth: We created a list called weekdays and added values of week days separated by spaces, and enclosed
with double quotation marks.
Fifth: We started a for statement to process the iteration that will be conditioned with 1 condition to
loop until the end of the list that we have created in the fourth step.
Sixth: We started instructing the computer to do something as long as the for statement in step five is
looping using the do command.
Seventh: We gave some orders to the computer to output the day name in the command we gave it to
the screen.
23
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
Eighth: We ended the commands we gave the computer to do by using done keyword.
Ninth: We have closed and saved the shell script file that we created in the first step.
Figure 1.12 shows the output of the script that we have created and procedures we did above.
Now that we need to know a little more about what we added in the file we created:
The variable is a place in memory that we can save data on and the name variable because we can change
the data stored in it to any value that we want.
We use $ dollar sign to call the variable that we have created and use it in any statement in the script.
Download now
24
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
The following commands examples can be used to install different packages and programs:
This command will make you install apache2 web server on your machine.
This command will make you install a java jar type file.
sudo sh netbeans.sh
This command will make you install a shell type file on the terminal.
These commands can also vary according to the file place you will install and examples are as follows:
sudo sh /home/username/Downloads/netbeans.sh
In case you have downloaded the file from the Internet on your machine and the file is now located for
example insudo apt-get install oracle-java8-installer the default downloads directory:
You need to provide the full path of the file as follows: /home/username/Downloads/filename.sh
Some shortcuts can be put into practice while using the LINUX terminal as follows:
If you want to directly access the Downloads default directory in you LINUX machine, you can simply
type: ~/Downloads/filename.sh
This way you eliminated the use of /home/username/ by using ~/ only.
Another shortcut example is by using ~/Desktop/filename.sh you are accessing a file located on your
desktop directory.
If you want to browse the content of a directory to get the files within this directory use the following command:
ls -l /path/to/directory/
An example that shows how this command works with its output will be in the next figure 1.13.
25
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
One more thing to go, is when you perform a java -jar file installation or execution, you need first to
have java sdk installed on your machine and this can be done using the following command:
And if you want the Oracle version of java, you can use the following commands to install it:
Be very careful when installing these commands and examine exactly what to install before performing
the installation steps.
You can add a repository, manage repositories and use these repositories in your installations and
system update.
Repositories are assemblies of installation and update files grouped together in one place with a unique
URL that can be bound to your system using a file called sources.list and this file can be edited using a
regular text editor and can be modified also using the terminal.
1st Lets add a repository to our sources.list file by using this command:
26
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
nano /etc/apt/sources.list
You can edit in the file, add, update or delete any record you need but be
very cautious when working with this file because it contains some sensitive
data about updating and upgrading packages of your operating system.
27
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
The output of this command is a part of the output shown before in the section Basic LINUX Commands
#Image7|graphic
The output of this command is also a part of the output shown before in the section Basic LINUX
Commands #Image7|graphic
You can upgrade your LINUX distribution (only) means that you will upgrade within the same
distribution versions but not to the newest distribution using the following command:
The output of this command is also a part of the output shown before in the section Basic LINUX
Commands #Image7|graphic
Of course you can get around problems while performing update, upgrade, and dist-upgrade using
a key called --fix-missing and it will try to go around broken links and other update problems that
it may face during the process execution.
So basically, this is the end of part 1 LINUX Desktop, Server and Cloud Image which has added a general
idea of how LINUX machine is working and how to do various tasks id different area of management
of a LINUX machine.
28
LINUX for System Administrators and DevOps Linux Desktop, Server and Cloud Imag
2 Linux Infrastructure
2.1 Installing DNS, DHCP, and Kerberos
Lets walk through the installation of BIND9 which is the DNS Package Name on UBUNTU
Running this command will give the output with confirmation as figure 2.1 shows:
Download now
29
LINUX for System Administrators and DevOps Linux Infrastructure
When you press Y and hit enter key on your keyboard the installation will continue until finished and
you will get to the bind configuration process to get everything up and running.
You will be editing this file, please find a line of text containing forwarders:
forwarders{
00.00.00.00;
}
Please change the number between brackets from the current IP address to your IP address. In my case,
my IP address is 192.168.0.2
forwarders{
192.168.0.2;
}
Now, you need to enter the following command to edit another file called named.conf.local
Then, what you need to do is changing adding the following entries or changing the current entries
if found:
zone “manon.com” {
type master;
file “/etc/bind/db.manon.com”;
};
zone “0.168.192.in-addr.arpa” {
type master;
file “/etc/bind/db.192”;
};
Press CTRL + W to quit, confirm using Y, then hit enter on your keyboard.
30
LINUX for System Administrators and DevOps Linux Infrastructure
Now, you need to execute the following command to copy a file using cp keyword from the original
place and create your own with a suitable file name for this configuration situation:
The copied file is into the path /etc/bind/db.127 and copied to /etc/bind/db.192
After Copying the file, you should edit the copied file using the following command:
After that you will be presented with the file content, edit the file content and make it suitable for your
needs as follows:
;
; BIND reverse data file for local loopback interface
;
You will find the area that you should edit are highlighted so you can customize it according to your
needs and put into consideration that the last line is containing the number 2 at the beginning will be
the last octet in your IP address.
When you finish this, you need to start copying another file using this command:
this command is copying a file from location /etc/bind/db.local to the destination /etc/bind/db.manon.com
Do not forget to change your destination file from db.manon.com to your host name that you desire
your server string will be.
31
LINUX for System Administrators and DevOps Linux Infrastructure
After finishing this we need to edit the file db.manon.com to change its content as follows:
Download now
32
LINUX for System Administrators and DevOps Linux Infrastructure
I have highlighted the editable areas for you to change it to your specific environment as follows:
This way, you need to exit the editor using CTRL + X and confirm the file changes using Y, then you
need to hit enter on your keyboard to get back to the terminal.
We need to restart the service called bind9 that we have installed on the machine using this command:
sudo service bind9 restart
After restarting your service, please run this command to check whether your server is responding and
up and running:
Please replace the number 192.168.0.2 with your IP address of the server that you are installing this
DNS on it.
33
LINUX for System Administrators and DevOps Linux Infrastructure
But if you did not see this message, please revise the section about trouble-shooting your LINUX machine
in Appendix B ................................................................ Troubleshooting your LINUX Machine DNS
Please do not consult Appendix B before you make sure you made the previous steps exactly as requested.
Our next step will be installing DHCP on your LINUX machine as follows:
34
LINUX for System Administrators and DevOps Linux Infrastructure
After running this command, you will be presented with the following output as the following figure 2.3:
Download now
35
LINUX for System Administrators and DevOps Linux Infrastructure
After running the previous command, you need to make some changes in the configuration as follows:
You will now edit the file by searching the content of the file for a line called
You need to edit the contents of the file to make it like the following content starting from this file until
the end of the content below:
default-lease-time 600;
max-lease-time 7200;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.0.255;
option routers 192.16.0.254;
The previous configuration has assigned the ranges from 80–100 to the clients of the subnet and from
120–220 to the same subnet.
What does this mean? If any computer is going to join this domain as illustrated in the figure
#Image4|graphic in this book that contained the infrastructure sample of connected computers, printers,
tablet, etcetera, every device of these will obtain an IP address within the ranges that you have specified
in this DHCP server.
One more thing to go with the previous installation is to restart the DHCP server using the following
command:
36
LINUX for System Administrators and DevOps Linux Infrastructure
The following figure 2.4 shows the 2 installations that we did and how they relate to the network
infrastructure that you are building:
Our LINUX distribution here will be installed on the cluster controller machine in the Data Center RAC.
Our DHCP server will be installed on this machine and its function will be to distribute the IP addresses
to PCs, Big Tower PCs, and Printers that are hooked to the BUS topology network.
If you look carefully at the Data Center RAC, SAN ISCSI storage disk, which will be manageable also
by the cluster controller node when installing the file server in later chapters.
You will be prompted to enter the REALM name, for example if you made your DNS name in the DNS
installation step as manon.com, then the realm name will be MANON.COM capitalized.
After that, you will be prompted to enter kerberos servers and administrative servers for your realm
as follows:
37
LINUX for System Administrators and DevOps Linux Infrastructure
38
LINUX for System Administrators and DevOps Linux Infrastructure
After the previous installation, we need to install LDAP utilities using the following command which
will work as a back-end for our PHP front-end that we will install later after this installation:
When you finish this installation we need to re-configure the package slapd by using the following
command:
After running this command, you will be presented with the following:
This will be the front end for our LDAP server and will be working as a user interface for managing
LDAP users and groups.
After the installation finishes, we need to edit the following file using nano as follows:
$servers->setValue(‘server’,’host’,’manon.com’);
The fields that you need to change according to your environment are highlighted in yellow.
39
LINUX for System Administrators and DevOps Linux Infrastructure
$servers->setValue(‘server’,’base’,array(‘dc=manon,dc=com’));
And also the fields that need to change are highlighted in yellow.
The final step is to fine the following line of code to change it to the following values:
$servers->setValue(‘login’,’bind_id’,’cn=admin,dc=manon,dc=com’);
You will also find the fields that need to be edited are highlighted in yellow.
When you are finished, please open your browser and point it to the following address putting into
consideration to change it according to your environment specifications:
http://manon.com/phpldapadmin/
After opening this screen, you will be presented with user name and password, and you need to enter
the user name as follows and putting into considerations the changes in your environment:
cn=admin,dc=manon,dc=com
Now, we have completely installed our LDAP Kerberos on our DNS and remains the security part that
we will come to apply it in the chapter Security in LINUX.
40
LINUX for System Administrators and DevOps Linux Infrastructure
You need to change manon word to the user name you will need in your environment.
It will prompt you to enter the details of the user and confirmation that these details are correct
or not.
If you want to make this user as administrator and can perform all kinds of tasks on the machine, please
execute the following commands as follows:
sudo visudo
Download now
41
LINUX for System Administrators and DevOps Linux Infrastructure
You will find your self into the text editor that we had to use before and we will edit some
lines as follows:
search for the line that contains the user name that you have just created in the command
adduser in the terminal and change the line to the following:
• If you want to delete the user, you can use the following:
If you want to delete the user with all the files that belong to this user on the system, then you can use
the following command:
sudo visudo
To comment it and make it useless into the file if you will use it later.
• Creating a group
If you want to create a group, then you will need to execute this command:
This way, you have added a new group of users into your LINUX machine.
42
LINUX for System Administrators and DevOps Linux Infrastructure
If you want to join the user into this group, then execute the following command:
This way, we have joined the user “manon” to the group “manonsys”.
If you want to change the user privileges to access or deny access to directories (folders), files, etcetera,
then you will need to go to chapter Installing and Managing FTP, SFTP which we will talk about file
servers and managing directories and installing protocols that enable the users to communicate with
the system directories.
To install your firewall on LINUX, you need to issue the following command on your terminal:
This command might give the package is installed already and the newest version because it might be
installed with your operating system by default.
If you finished installing the package, we need to enable it by issuing the following command:
To show the status of your firewall, you need to execute the following command:
43
LINUX for System Administrators and DevOps Linux Infrastructure
You will be presented with a screen like the previous 2.7 figure showing the results of the previous
command.
Download now
44
LINUX for System Administrators and DevOps Linux Infrastructure
To enable a port number on your machine, we will execute the following command:
This command will enable the traffic to pass in and out on port 53.
We will also learn what are ports when working on securing your LINUX distribution, installing web
servers on LINUX, and installing ssh and file servers on LINUX because every installation of these will
require 1 port number or more to use within the installation.
Every service of these can be added to the rules of the firewall we are using by allowing or denying it.
This will deny port 53, and the result of the previous command will be identical the command that we
issued for enabling the same port.
If you want to allow or deny a specific port with a specific protocol, you need to issue the following
command:
This command will make port 53 enabled for use with the TCP protocol only.
45
LINUX for System Administrators and DevOps Linux Infrastructure
If you want to disable the same port with the same protocol, you need to need to execute the following
command as follows:
1 more thing to go, is if you want to enable a UDP protocol with any port, you can execute the following
command:
And if you want to disable a UDP protocol with any port, you can execute the following command:
Finally, if we want to disable the firewall completely, then we need to execute the following command:
Now, we have managed our LINUX firewall and learn how enable, disable, and manage ports to accept or
deny specific protocol on a specific port number or accept or deny all port number protocols in general.
Apache® web server is ranked #1 in the world ranking statistics of web servers, this is why we will focus
on installing a server stack on our LINUX machine called LAMP.
The LAMP abbreviation stands for LINUX, Apache, MySQL, and PHP.
To install the LAMP stack on your UBUNTU LINUX machine, we will execute the following commands:
When this execution is finished, we need to execute the command that will install the stack itself as follows:
46
LINUX for System Administrators and DevOps Linux Infrastructure
This command will order tasksel that we installed before to install lamp-server package.
You will be prompted to enter the password, and confirm it for your MySQL database server.
After that, when you finish walking through the procedures of the previous command, we will install a
GUI for managing our database server called PHPMyAdmin.
PHPMyAdmin is a powerful tool that is used to manage MySQL databases, execute queries, manage
users and more.
Executing the command will lead you to enter your MySQL password, please enter the same passwords
that you entered when installing the LAMP server in the previous command, and you can also use the
same password for the management system account.
And you can permit the PHPMyAdmin to create it own database on MySQL server by selecting yes
when prompted.
Download now
47
LINUX for System Administrators and DevOps Linux Infrastructure
This way we have installed our LAMP stack, and a web server that we can use to host applications on
our UBUNTU LINUX machine.
To test our installation, we need to create a file called index.php and place this file in the following
directory:
/var/www/html/
This will open a text editor on the terminal window to add some text.
<?php
echo phpinfo();
Then we need to press CTRL + X to close the file and confirm the changes by typing “Y” and then hitting
enter on the keyboard to confirm the path and file name.
After finishing all the requirements, we need to open a browser and point the address to the following
URL:
http://localhost/
This will make you see the following figure 2.9 which will contain all the server configuration settings
for your PHP installation.
48
LINUX for System Administrators and DevOps Linux Infrastructure
If you face any problem, please consult the Appendix F Troubleshooting your LINUX Web Server.
1. We need to install a package called POSTFIX on our UBUNTU LINUX operating system.
Installing this package is done by executing the following command:
sudo apt-get install postfix
You can simply accept the default because we will be working on re-configuring the package.
2. We need to re-configure the package in order to apply our environment specific data as follows:
sudo dpkg-reconfigure postfix
You will be presented with a series of screens where you need to apply your configuration settings
as follows:
• Internet Site.
• None doesn’t appear to be requested in the current config.
• System mail name will be manon.com and you need to change it to the domain that you
have chosen when installing your DNS.
• mostafa #adjust it to use your own user name.
• manon.com, localhost, localhost.localdomain, localhost #adjust manon.com to your own
string used when installing your DNS.
49
LINUX for System Administrators and DevOps Linux Infrastructure
• No.
• 192.168.0.2 #Adjust it to your own IP address.
• Yes
• 0
• +
• all
Now we need to run the following series of commands 1 by 1 to continue with the configuration process:
50
LINUX for System Administrators and DevOps Linux Infrastructure
51
LINUX for System Administrators and DevOps Linux Infrastructure
Next, we need to install the following packages to complete the security of our POSTFIX mail Server
as follows:
PWDIR=”/var/spool/postfix/var/run/saslauthd”
PARAMS=”-m ${PWDIR}”
PIDFILE=”${PWDIR}/saslauthd.pid”
After that we need to change the OPTIONS line at the end of the file to be:
OPTIONS=”-c -m /var/spool/postfix/var/run/saslauthd”
If the previous command produces a warning or error, ignore the error because the directory reported
will be created automatically in the next steps.
52
LINUX for System Administrators and DevOps Linux Infrastructure
telnet localhost 25
OR
ehlo localhost
OR
ehlo manon.com
Download now
53
LINUX for System Administrators and DevOps Linux Infrastructure
This way, we have completed our installation or our mail server and let us integrated into our LAMP
Web Server and Send our First HTML formatted Web Mail.
Execute the following command to edit the PHP.ini configuration file as follows:
Search in the file for an entry called sendmail_path and change it to sendmail_path = "/usr/
sbin/sendmail -t -i"
Now execute the following command to create a file called sendMail.php to send your first mail using
the following command:
<?php
$to = “mailofpersontosendto@hotmail.com, anothermailtosendto@gmail.com”;
$subject = “HTML Mail Subject”;
$message = “
<html>
<head>
<title>Title of the E-Mail</title>
</head>
<body>
<p>This is an HTML E-Mail Message !!!</p>
<table>
<tr>
<th>Column 1 Header</th>
<th>Column 2 Header</th>
</tr>
<tr>
<td>Content of Column 1 in HTML E-Mail</td>
<td>Content of Column 2 in HTML E-Mail</td>
</tr>
</table>
</body>
</html>
“;
54
LINUX for System Administrators and DevOps Linux Infrastructure
if(mail($to,$subject,$message,$headers)){
echo ‘Mail have been send successfully as desired.’;
}else{
echo ‘We have encountered some error, please consult <br />Appendix G Troubleshooting your
LINUX Mail Server’;
}
http://manon.com/sendMail.php
OR
http://localhost/sendMail.php
After visiting this URL, you will be noticed if the mail message has been sent or not.
Now, we have completely installed LINUX mail server and you can enjoy sending mails.
When finishing your installation, please run the following command to configure your FTP server
settings:
55
LINUX for System Administrators and DevOps Linux Infrastructure
anonymous_enable=NO
local_enable=YES
write_enable=YES
chroot_local_user=YES
Save and Exit by Pressing CTRL + X, and then Press Enter Key on Your Keyboard.
sudo mkdir /home/manon/files #changing manon with your operating system’s user name.
Download now
56
LINUX for System Administrators and DevOps Linux Infrastructure
Now, connect to your FTP server by executing the following command from the terminal as follows:
We use the user name of the operating system that we have used while doing the previous tasks, then
we put the password of that account.
When finished, type exit on the terminal to terminate your ftp session.
When installed, start your filezilla application and put in the host field: ftp://manon.com/
When finished, click connect and now, you have connected to your file server.
You can create directories on your server, create files, and manage it.
Open start menu and type map network drive in the search box.
In the location field, type the FTP server name which is ftp://manon.com/
When prompted, type the user name and password we just mentioned earlier.
To install the secured layer of FTP which is SFTP, we need to execute the following command:
57
LINUX for System Administrators and DevOps Linux Infrastructure
After finishing the installation, we will be able to connect to the server using SFTP using the URL:
Now, let us connect to FTP and SFTP using our tablet device as follows:
I will use an iOS enabled tablet device to and browse store applications on Apple® app store and find
an application called FTPManager Free®.
After installing your application on your iPad or iPhone, you will find a + sign at the main menu of the
application used to add a server connection
You are now connected to your file server and you are ready to move, and add files to your server.
Now, we covered working with our file server installation, configuration and management.
[share]
comment = Ubuntu File Server Share
path = /srv/samba/share
browsable = yes
guest ok = yes
read only = no
create mask = 0755
58
LINUX for System Administrators and DevOps Linux Infrastructure
This way, we have configured and installed our SAMBA File Server and Created a Share, so if you browse
any Windows OS machine network tab to browse the computers of the network, you will find that our
server’s share appears to all windows users.
Download now
59
LINUX for System Administrators and DevOps Linux Infrastructure
After that, we need to assign a user name for anyone to connect to the machine using it as the following
command:
Now let us create our first repository by adding our web directory that has been created when we installed
our web server by executing this command:
If you face any problems with the previous command, you need to issue the following command instead
Now we do clone to the repository using our user name and password
cd /path/to/repository
Then we make something called commit and give a message to it or leave it blank as follows:
git commit -a
60
LINUX for System Administrators and DevOps Linux Infrastructure
or
There is another git server that performs the same functionality as the previous GIT server that we have
installed. Lets walk through the installation of this server as follows:
When finished, add a new user to the system called GIT by executing the following command as follows:
sudo adduser --system --shell /bin/bash --group --disabled-password --home /home/git git
Now we need to consult installing SSH server and client on your machine article and follow the following
commands:
ssh-keygen -t rsa
Accept defaults and just hit enter on your keyboard until finished, then execute the following command:
cp ~/.ssh/id_rsa.pub /tmp/$(whoami).pub
Then, we need to login to the user that we have created using the following command:
sudo su - git
gl-setup /tmp/*.pub
Now, you need to exit the session of the user that we logged in by executing the following command:
exit
61
LINUX for System Administrators and DevOps Linux Infrastructure
All what you need to do is: To change the manon.com with your computer’s DNS name as you chose
when installing your DNS server which is highlighted in yellow.
Now you can browse the content of the project using the following commands:
cd gitolite-admin
ls -l
To add the repository to an existing project, you can execute the following command as follows:
Now, we have finished installing, configuring, and using our GIT server and client.
62
LINUX for System Administrators and DevOps Security in Linux
3 Security in Linux
3.1 Installing SSH
SSH server is used to connect to your machine using secured socket layer with encryption mechanisms
like using key pairs for private and public.
The concept of private and public key pairs are for use as follows:
The private key stays on the destination machine in a standard encryption format and usually SHA-256
encryption mechanism alongside with SHA-2 and RSA which is the basic encryption mechanisms.
ssh-keygen -t rsa
ssh-copy-id mostafa@manon.com
Then we give enough privileges to our keys directory to make sure that everything is secured.
If you want to access your shell using a web browser, we need to install the following package and make
some edits and configurations as follows:
63
LINUX for System Administrators and DevOps Security in Linux
Now, open your browser and point to your machine using the following URL as follows:
http://manon.com:8022
#replacing manon.com with your own IP, or DNS String that you used on your DNS installation machine,
and you can also use localhost instead.
Type in your user name, then hit enter key on your keyboard.
You of course enter the user name and password of your own operating system’s.
The following figure 3.1 shows the outcome of the previous installation.
64
LINUX for System Administrators and DevOps Security in Linux
Note that server.key can be changed to any file name that you have used.
Now we assign RSA enctryption to our key file and put the result out to an insecure file as follows:
mv server.key server.key.secure
mv server.key.insecure server.key
Download now
65
LINUX for System Administrators and DevOps Security in Linux
Now, submit all the files to a signing authority like Comodo® as an example of a certificate signing
issuing organization on the following URL:
https://www.instantssl.com/free-ssl-certificate.html
Complete the wizard, submit your certificate key, verify your DNS by hosting the requested file over
HTTP or HTTPS, and also there are several other options to do that.
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
After running the previous commands which is creating key files and related directories, we need to edit
in the configuration of our operating system openssl package configuration file as follows:
We need to find the following values and edit them carefully as follows:
dir = /etc/ssl/
database = $dir/CA/index.txt
certificate = $dir/certs/cacert.pem
serial = $dir/CA/serial
private_key = $dir/private/cakey.pem
If you made changes to the files names that we created above in the previous commands, you also need
to apply the same changes to this configuration file to be in parallel.
66
LINUX for System Administrators and DevOps Security in Linux
Now, we need to request the the self signed root certificate as follows:
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650
Also, we need to move the key files the default directory as follows:
Now there is a new file in the following directory called /etc/ssl/newcerts/01.pem, we need to rename
this file to our needs and move it to the following directory with the new name as follows:
Now, we need to configure our https server to use this certificate that we have created using the following:
SSLCertificateFile /etc/ssl/certs/manon.com.pem
SSLCertificateKeyFile /etc/ssl/private/server.key
67
LINUX for System Administrators and DevOps Security in Linux
When we edit the file it will be looking much like the following figure 3.2 as follows:
Now we can press CTRL + X to close this screen and press enter key on the keyboard to save everything.
Download now
68
LINUX for System Administrators and DevOps Security in Linux
When finished, we need to restart our apache server by issuing the following command as follows:
During the previous process, there would be some prompts, like passwords, country names, user file
names, and city and state values. You can of course use your own values, or the values specific for
your needs.
When you are finished with everything, you browse your https://manon.com server and confirm your
security exception to add the website to the trusted sites, click on the little icon beside the address
https://manon.com/ directly and you will find that a windows opens to you, click on more information,
then go to the security tab if not enabled by default and then click view certificate, then you will find
that the certificate is populated with your protocol with the server name manon.com as you will see in
the following figure 3.3 as follows:
69
LINUX for System Administrators and DevOps Security in Linux
There are 2 main options to configure SELINUX packages, we will mention them with how to enable
each one of them as follows:
• Permissive: manon.comMost popular option and the command to enable this option is:
sudo sed -i ‘s/SELINUX=.*/SELINUX=permissive/’ /etc/selinux/config
• Enforcing: The most secure option and the command to enable this option is:
sudo sed -i ‘s/SELINUX=.*/SELINUX=enforcing/’ /etc/selinux/config
UFW
UFW is installed by default as we said and we will go through its configuration and manipulation
commands as follows:
To enable or disable a port on one of the services you are using like HTTP or HTTPS, we need to issue
toe following commands
The previous port number 8080 and 80 are the mainly used port numbers by UBUNTU for HTTP
protocol. If you disabled one of these ports, you will not be able to browse your http://localhost/ or
http://manon.com/ from other machines.
70
LINUX for System Administrators and DevOps Security in Linux
You can also delete a rule that you have created as follows:
You can also call allow, deny services by service name using the following command:
Finally, we can enable and disable the service using the following command:
Download now
71
LINUX for System Administrators and DevOps Security in Linux
ssh localhost
We use this command to connect to the machine locally within our local network.
If we obtained a static IP address service from our service provider and applied it to our LINUX
connection, we will be able to connect to our machine anywhere using the following command:
ssh 192.168.0.2
Replacing 192.168.0.2 with your ISP IP address that you will gain.
You can also connect to your machine using the DNS string that we used while working on installing
your DNS on your UBUNTU LINUX machine as follows:
ssh manon.com
You will need a user name and a password to access the machine and if you have a public – private key
pairs installed like we mentioned in #Creating Certificates using SSL section that was containing your
key files that we created.
OR
Enter the pass pharase that you used while creating your file.
Enter the operating system’s password that you use to login to the system.
And, you will be presented with the following screen as in figure 3.4.
72
LINUX for System Administrators and DevOps Security in Linux
This way you can fully control your machine remotely and perform any task on it.
We have now covered the topic on how to connect to your machine using SSH service.
73
LINUX for System Administrators and DevOps Security in Linux
Httrack
Burp Suite
Web Scarab
You can search the web also for HTTP scanning tools and perform a scan on your machine
as a target.
There are also online scanning tools that you can use on your browser.
Add the following line of code to the file that we have created as follows:
Options -Indexes
Save the file using CTRL + X and then confirm the file location and same file name by pressing
enter key on your keyboard.
When you finish try opening an empty directory in your web server, and you will end up with
an error of permission denied notice page on the web browser.
mysql_secure_installation
Enter the root password that we used when installing database server or LAMP server when prompted.
74
LINUX for System Administrators and DevOps Security in Linux
In the change root password prompt, you can change it or not according to your environment by typing
Y or N as Yes or No options.
In the disallow root login remotely select Y for the sake of security, just not to let someone from another
machine even on the same network to login to the database server.
In the remove test database and access to it prompt, select Y and hit enter.
Noice that, you will be presented at the end of our configuration with the following screen as figure 3.5.
But notice that in my state, I have allowed my remote login attempt to make the server available for
accessing it remotely and this option will be recommended for Cloud Image installation, if you are using
UBUNTU in a cloud environment, then you will use this option because you will be connecting to your
database server remotely.
75
LINUX for System Administrators and DevOps Networking in Linux
4 Networking in Linux
4.1 Wired Networking in Linux
There are several ways to work with networking in LINUX. Networking is divided into wired, wireless
and cellular connections.
We will walk through wired and wireless standards only in the scope of this book due to the variations
in the standards of the cellular connections and supportability on LINUX infrastructure.
To list the interfaces (network adapters) that are currently available on your machine, we can execute
the following command as follows:
ls /sys/class/net
Download now
76
LINUX for System Administrators and DevOps Networking in Linux
We can also get a list of the currently available network interfaces using the following command which
will give us more details about every interface.
ip addr
Figure 4.2 Shows the output of listing the interfaces in more details.
sudo vi /etc/network/interfaces
If you want to configure you network adapter to use a static IP address, then we need to add the following
lines to the file that we are editing as follows:
auto eth0
iface eth0 inet static
address 192.168.0.2
netmask 255.255.255.0
network 192.168.0.1
broadcast 192.168.0.255
gateway 192.168.0.1
dns-nameservers 192.168.0.1
Figure 4.3 shows the configuration settings above that we have to apply to our network adapter.
77
LINUX for System Administrators and DevOps Networking in Linux
This way, we have configured our wired networking adapter to use a static IP address that we assigned.
sudo ls /sys/class/net
ip addr
In most systems on LINUX machines, this is the default name for the wireless adapter that you work
with, and if you have installed more that one adapter to your machine, you will find them named wlan1,
wlan2, wlan3, etcetera.
We need to issue the following command to get to edit our networking interfaces and adjust an static
IP address as follows:
sudo vi /etc/network/interfaces
auto wlan0
iface wlan0 inet static
address 192.168.0.2
netmask 255.255.255.0
network 192.168.0.2
broadcast 192.168.0.255
gateway 192.168.0.2
dns-nameservers 192.168.0.2
Now press CTRL + X to save the file, confirm using the same path and name.
78
LINUX for System Administrators and DevOps Networking in Linux
Or
Download now
79
LINUX for System Administrators and DevOps Networking in Linux
The first 3 commands are used to start, stop, then re-start the service in some UBUNTU LINUX
distributions and FEDORA distributions.
The last 3 commands are used to start, stop, then re-start the service in some other UBUNTU
distributions only.
If you are using cloud images in UBUNTU or FEDORA, or what ever the distribution you are using is,
you can install the network manager service as follows:
To install the indicator on GNOME distributions, you can use the following command as follows:
When you finish, we need to link the installation to our web server as follows:
We can restart the apache service after all to complete the process as follows:
When finished, we have everything now working by pointing to the following URL:
http://manon.com/bandwidthd/
80
LINUX for System Administrators and DevOps Networking in Linux
Figure 4.4 shows the console of the network bandwidth monitoring tool.
Download now
81
LINUX for System Administrators and DevOps Networking in Linux
Port scanning is a way to know what are the opened ports for every device that we perform the scan on.
IP scanning, is a way to know what are the IP addresses that are up and running on my network.
We need to install nmap service protocols on your UBUNTU LINUX machine as follows:
When finished, we need to perform IP scanning on the network to know which devices are connected
to it as follows:
To scan a range of IP addresses in your network, we need to execute the following command as follows:
192.168.0.0
192.168.0.1
192.168.0.2
192.168.0…
192.168.0.255
Now, we have an output like what we see in the next figure 4.4.
Next, we need to check what are the opened ports on each host as follows:
82
LINUX for System Administrators and DevOps Networking in Linux
Now, we can monitor the network and subnet bandwidth, scan network hosts by IP range and get the
details of every host connected to network.
83
LINUX for System Administrators and DevOps Private Cloud in Linux
One of the products that has a big market share in the cloud computing industry. Most of today’s companies
and possibly the most of the biggest companies in the cloud services providers like Canonical, IBM, Redhat,
Rackspace, Dell, HP, CISCO, Cloud Scaling, Poston, SUSE, Nebula, and VMWare which is nearly the ranking
#1 cloud operating system in the world.
Let us walk through the installation of openstack using a management tool called devstack.
To start our installation let us type in the following command as follows:
If you did not walk through the installation of GIT, please go the section called installing git client and
install git to get this command working with you.
When it finishes downloading, you need to change the permissions of your download as follows:
sudo chmod 777 -R ~/devstack
cd ~/devstack
Then we start the installation script as follows:
./stack.sh
When prompted enter the same password that you used when you installed your LAMP server. Or if you
did not install any database servers, you can use any new password and recommended to be of letters
and numbers.
84
LINUX for System Administrators and DevOps Private Cloud in Linux
After all, we need to walk through a series of downloads and installation procedures done automatically
with the execution of this script, then we finish up with a screen like follows:
Figure 5.1 shows the confirmation screen containing the URL of the service and credentials (user name and password)
When finished, you will be presented with the screen containing how to access the services that we have
installed as the previous figure is telling.
Now open your browser and point to the any of the following URLs:
http://manon.com/auth/login/?next=/
http://manon.com/auth/login/
http://manon.com/
You need to change the following previous URL domain name to your DNS string or you can use localhost
or your IP address if you are using the same machine.
85
LINUX for System Administrators and DevOps Private Cloud in Linux
On the home screen, you will be presented with the following screen as figure 5.2 shows:
If you finished typing your user name which is demo or admin and your password as entered during
installation, and you click on connect, you will be presented with the dashboard.
This way, we have installed our openstack services completely and functional.
Download now
86
LINUX for System Administrators and DevOps Private Cloud in Linux
We will create a project, user name and password, create a role, and add the user to the role as follows:
You will end up with a screen like the following figure 5.3
sudo openstack user create --project admin --password PASSWORDHERE manon --os-
username=admin --os-password=INSTALLATIONPASSHERE --os-auth-url=http://192.168.0.2:5000/
--os-project-name=admin
When running this command, we will be presented with the following screen of confirmation as the
following figure 5.4:
This way we have created a new user into our openstack service and we can now login in with the new
credentials that we have created.
87
LINUX for System Administrators and DevOps Private Cloud in Linux
Then fill in the user name and password that you have used in the previous command and you are good
to go.
Figure 5.5 shows the users that we have including the user that we have created highlighted in black background color.
To enable the user that we have disabled, we need to execute the following command as follows:
88
LINUX for System Administrators and DevOps Private Cloud in Linux
To add the user to the role, we can execute the following command:
sudo openstack role add --user manon --project manon manonrole --os-username=admin --os-
password=INSTALLATIONPASSPHRASE --os-auth-url=http://192.168.0.2:5000/ --os-project-
name=admin
The output of the previous command is the same as the output of the figure 5.6.
Download now
89
LINUX for System Administrators and DevOps Private Cloud in Linux
To update the name of the project, we can execute the following command:
To show the details of a project, we can execute the following command as follows:
We can also use the same commands that we have used now to edit a project against editing users and
roles with the same keys that we have used in the previous commands like –os-username –os-password
–os-auth-url and –os-project-name
These keys are mandatory and must be used within your commands execution procedure or can be
stored in a file under each other and load that file into the terminal window and execute the commands
without the need to assign these values every command execution.
touch adminrc
90
LINUX for System Administrators and DevOps Private Cloud in Linux
OS_USERNAME=manon
OS_PASSWORD=password
OS_AUTH_URL=http://localhost:5000/
OS_PROJECT_NAME=admin
You have to press CTRL + X to exit the text editing screen and confirm the file path, and name by hitting
the enter key on your keyboard.
Then execute the following command before executing any other commands that we have listed above
as follows:
source adminrc
Then you need to execute the command as an example after sourcing the adminrc script that we have
created as follows:
Now, we have completed the administration procedures of Openstack identity services called keystone.
Then you need to enter the password that we have entered when installing your LAMP server, or
when installing MySQL database server or when installing devstack that we walked through in the
previous steps.
After that, you will be presented with the following screen as follows:
When finished, we need to create a new database called heat and grant access to it as follows:
91
LINUX for System Administrators and DevOps Private Cloud in Linux
Now, type exit and you will find confirmation of bye message.
Next, we create a user that we will delegate the heat orchestration services to as follows:
sudo openstack user create --project admin --password PASSWORDHERE heat --os-
username=admin --os-password=INSTALLATIONPASSHERE --os-auth-url=http://192.168.0.2:5000/
--os-project-name=admin
Download now
92
LINUX for System Administrators and DevOps Private Cloud in Linux
sudo openstack role add --user heat --project manon manon --os-username=admin --os-
password=INSTALLATIONPASSPHRASE --os-auth-url=http://192.168.0.2:5000/ --os-project-
name=admin
After all, we need to create 2 endpoints that will be needed when working with Heat API.
Endpoint is a place where integration gateway works between 2 services or more, or used to communicate
with a system from another.
The first endpoint we create is heat for the heat user and heat role that we have created as follows:
93
LINUX for System Administrators and DevOps Private Cloud in Linux
connection = mysql://heat:HEAT_DBPASS@controller/heat
rpc_backend = rabbit
rabbit_host = localhost
rabbit_password = guest
heat_metadata_server_url = http://localhost:8000
heat_waitcondition_server_url = http://localhost:8000/v1/waitcondition
auth_uri = http://localhost:5000/v2.0
identity_uri = http://localhost:35357
admin_tenant_name = admin
admin_user = heat
admin_password = PASSWORDHERE
Then, we need to edit the following line in the section called [ec2authtoken]
auth_uri = http://localhost:5000/v2.0
If you are using UBUNTU LINUX, then we need to issue the following command to remove unused
database as follows:
rm -f /var/lib/heat/heat.sqlite
94
LINUX for System Administrators and DevOps Private Cloud in Linux
touch heatorehcstrationtemplate.yaml
nano heatorchestrationtemplate.yaml
After all, we need to add the following content to the file and considering any changes according to our
environment as follows:
heat_template_version: 2013-05-23
95
LINUX for System Administrators and DevOps Private Cloud in Linux
resources:
my_instance:
type: OS::Nova::Server
properties:
image: /path/to/image/downloaded_ubuntu_cloud_image.img
flavor: m1.small
key_name: keyfile.pem
networks:
- network: network-name
After all, we can use our file in the following command to create a heat orchestration stack as follows:
Now, we have installed our heat services, made a complete configuration to make it work properly and
created a sample stack on the heat service.
Then, we need to enter the following data and notice that changes you need to make according to your
environment as follows:
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 192.168.0.2
[account]
max connections = 2
path = /srv/node/
96
LINUX for System Administrators and DevOps Private Cloud in Linux
Then we need to search for the line that contains the following data and
edit it as follows:
RSYNC_ENABLE=true
This way we have created the directories where the synchronization happens
on the destination medium that will save our re-synchronization data.
Now, we finished working with storage services installation and making our
basic synchronization services.
97
LINUX for System Administrators and DevOps Private Cloud in Linux
Now, confirm all the commands by pressing Y and hitting enter key on your
keyboard.
Download now
98
LINUX for System Administrators and DevOps Private Cloud in Linux
We have now installed our glance service and now, let us have to inject our
first image that we will download from UBUNTU cloud images directory over
the Internet at the following URL as follows:
https://cloud-images.ubuntu.com/wily/current/
This is the last release from UBUNTU LINUX developed by a company called
Canonical LTD.
This distribution is one of the most popular cloud images that can be used.
We can now use this image and import it in our Openstack private cloud as
follows:
Now that we have completed our Openstack Services installations and configurations.
We have also used some of its services, We also learned how to work with LINUX and learned what are
the distributions, repositories, basic commands, and most of the features that LINUX can do.
We also installed basic infrastructure with some advanced features and components from 3rd parties
and other vendors.
Thank you so much and appreciate your precious time reading the book.
Hope you enjoy it.
99