VCEWin

Learn By Self | Served By Experts

Buy Here: AWS Cloud Step By Step Lab Manual Guide

Deal of the month

Windows Server 2016 Hands-on Practical Guide with Virtual Machine Lab Setup

  • CCNA
    • Routing
    • Switching
    • IPv6
    • Security
    • Juniper
  • GNS3 Labs
  • VMware
  • VirtualBox
  • Windows
    • Windows Server 2016
    • Windows 10
    • SCVMM
  • Linux
    • Ubuntu
    • RHEL
  • AWS Cloud
  • Blogging Tutorilas
    • Internet Tips
You are here: Home / Archives for Linux

May 18, 2017 by VCEWin

Setup Password Authentication With Apache In Ubuntu Linux

In the previous post, we have explained the basic Apache configuration in Linux. The default web configuration everyone to access web content over the HTTP protocol. By somehow reasons, it may be required that the web content should be protected with a password. If you need that anyone who wants to access restricted content should only get after supplying a valid username and password, you will need to setup password authentication with Apache. In this tutorial, we are going to explain how to setup password authentication with Apache. We are using Ubuntu 17.04 system, for other Linux variant you may need to adjust some commands. However, the basic configuration steps and concept would remain almost same for all the Linux-based Apache configuration.

Recommended articles:

  • Setting up ssh key-based authentication
  • Configuring NFS in Ubuntu Linux
  • Configuring Samba in Ubuntu 17.04

We assume that you have an already configured Apache server with basic settings. If not, refer this article to configure the Apache server first.

In order to setup password authentication with Apache, you will be required to follow the following instructions:

1.Installing Apache Utility Packages

Run the following command to install the apache-utils package require to setup password authentication for Apache web server.

sudo apt install apache2-utils

2.Creating a User For Apache Authentication

Now, you need to create a user that will be used by end-users to get authenticated and access the restricted web content. In the below example, we are creating a user named protech.

sudo htpasswd -c /etc/apache2/.htpasswd protech

Note: Use -c only when you execute this command first time. For adding the additional users, use the htpasswd command without -c.

Use the following command to verify that user is added.

cat /etc/apache2/.htpasswd

Setup password authentication with apache in ubuntu linux

Add additional users as per your requirements.

3.Configuring Password Authentication With Apache

Adjust the apache configuration options to serve the protected web content with username and password authentication. You can setup password authentication with Apache server using any of the following two methods:

  1. Using the apache configuration file
  2. Using the .htaccess file

3.1 Setting Up Password Authentication With Apache Configuration File

In order to protect the web content using the username and password, you need to modify the /etc/apache2/sites-enabled/000-default.conf file. In the below example, /var/www/html is the apache content directory that we want to protect and /etc/apache2/.htpasswd is the file which contains the users details.

Modify the 000-default.conf file and append the content shown in the white text box.

Enabling password authentication with Apache using apache config file.

Now, restart the apache service and try to access the web server. You should be asked to enter the username and password to access protected web content. Use the user that you have added previously as shown in the following figure.

3.2 Setting Password Authentication Using .htaccess File.

If you are also interested in setting up password authentication with Apache using .htaccess file, follow the below instructions.

Edit the apache configuration file and replace the AllowOverride option from None to All under your web root directory. In our case, it is /var/www. The file should look like as follow.

Configuring password authentication in apache using .htaccess file

Now, you need to create the .htaccess file under the directory that you want to restrict. In our case, it is /var/www/html. In the .htaccess file, you need to specify the authentication type such as Basic and the location of .htpasswd file that contains the users’ details. The .htaccess file should look like as follow.

creating and modifying .htaccess file

Since we have already created a user in the .htpasswd file, let’s add one more user to test the .htaccess configuration. For this, execute the following command to add a user named gurus.

sudo htpasswd /etc/apache2/.htpasswd gurus

4. Restarting Apache Service

Next, restart the apache service and check the status to confirm that service is running properly.

sudo systemctl restart apache2
sudo systemctl status apache2

5. Testing Password Authentication With Apache

Open the web browser and try to access your website. You should be asked to enter username and password. If not asked, remove the browser history and reopen the browser. When prompted for authentication, use gurus user to authenticate yourself. You should be able to access protected web content. That’s all you need to setup password authentication with Apache web server.

In this tutorial, we have explained how to setup password authentication with Apache in Ubuntu. Hope, it helped you to configure Apache web server with password authentication. Write to us in the comment box if you face any issue while doing so.

May 18, 2017 by VCEWin

How To Configure Apache In Ubuntu Linux

Apache is the most preferred and popular open source web server. Most of the websites run with Apache platform. You can configure Apache in almost all the Linux variants including Ubuntu, RHEL, and Fedora. The configuration of Apache is not too much difficult. In this tutorial, we are going to explain how to configure Apache in Ubuntu Linux. We are using the latest version of Ubuntu that is Ubuntu 17.04. However, the same steps can also be used to configure Apache in earlier versions of Ubuntu such Ubuntu 14.04 and Ubuntu 16.04. For other Linux variants, you may need to adjust some of the steps mentioned in this tutorial but the basic concept would remain same for all the Linux variants.

Recommended articles:

  • Configure DNS in Ubuntu 17.04
  • Configuring LAMP in AWS Cloud using Ubuntu
  • Configure Samba in Ubuntu Linux

In order to configure Apache in Ubuntu 17.04, you need to perform the following tasks:

  1. Updating packages and upgrading system
  2. Installing Apache packages
  3. Configuring Apache Web server
  4. Testing Apache configuration

1. Updating Ubuntu Linux Packages

It is always the best practice to keep your system updated. In Ubuntu Linux, you can use the following command to update the packages and upgrade the entire system.

sudo apt update -y
sudo apt dist-upgrade -y

2.Installing Apache in Ubuntu Linux

Once the system packages are upgraded, install the Apache package using the following command.

sudo apt install apache2 -y

3.Configuring Apache in Ubuntu Linux

In order to configure Apache in Linux, you need to set the configuration options in the apache configuration file (/etc/apache/apache2.conf). In this file, there are various options that you can set as per the requirements. For this demonstration, let’s change the web server name from default to www.myserver.com. For this, add the following line in the Global Configuration section.

sudo vi /etc/apache/apache2.conf
ServerName www.myserver.com

3.1.Testing Apache Config File Syntax

Sometimes, you may modify something unexpected unintentionally in this file. So, it is always recommended to check the syntax of configuration file before to proceed. To test the apache config file syntax, use the apachectl command. The output should be Syntax OK as shown in the following figure.

apachectl configtest

Check Apache Config Syntax in Ubuntu Linux

3.2.Enabling and Starting Apache Service

Once you are done with your desired modification, restart and enable the Apache service using the following commands:

sudo systemctl restart apache2
sudo systemctl enable apache2
sudo systemctl status apache2

Configure Apache in Ubuntu Linux 17.04

3.3.Updating Hostname

We assume that you have already set the hosts configuration file. So you can access your web server with hostname along with IP address. If not, you need to add the following line in the /etc/hosts file.

<server-ip-address> www.myserver.com

Note:  For the production network, you may need to register the DNS name of your web server. Alternatively, you can also configure your own DNS server in Ubuntu.

Now, verify that your server is reachable using hostname as shown in the following figure.

Apache configuration in Ubuntu 17.04, Ubuntu 16.04, Ubuntu 14.04 Linux

4.Testing Apache Server Configuration

Now you have set all the apache configuration as per your requirement. Open the browser and test that your Apache server is working fine as shown in the following figure.

Testing Apache Configuration In Ubuntu Linux

That’s all you need to configure Apache in Ubuntu Linux. We would like to hear you if you have any further query or suggestions. In this tutorial, we have explained how to configure Apache Web Server in Ubuntu Linux.

However, here anyone can access your web server without restriction because we have not implemented any kind of web security. In some scenarios, you may need to set the user-based authentication to access Apache web server. This can be done by setting up the Password Authentication with Apache. Read out the below article to set the password authentication for your Apache web server.

May 15, 2017 by VCEWin

How To Configure Smaba In Ubuntu Linux

Samba is a service or you can say a protocol that allows you to share and access data between Linux and Windows systems. It is the basic protocol for sharing files and printers between Windows and Linux/Unix systems. In this tutorial, we are going to configure Samba in Ubuntu 17.04. However, the same steps can be used for earlier versions of Ubuntu such as Ubuntu 16.04. For other Linux variants, you may need to adjust some commands depending on the Linux variant you use. We will configure the samba server in Ubuntu as per the following requirements:

  • Samba share name: /home/sales
  • Permission: read and write
  • Allowed users: smbuser1
  • Network: 192.168.153.0/24

Recommended: Configure DNS in Ubuntu Linux 17.04

Steps To Configure Samba In Ubuntu Linux

In order to configure samba in Ubuntu Linux, you need to perform the following steps:

1. Installing Samba Packages

Use the following command to install samba packages in Ubuntu Linux

sudo apt install samba –y

2. Creating a Samba Share and Setting the Permissions

Use the following commands to create a samba share and set the permissions

sudo mkdir –p /home/sales
sudo chmod 770 /home/sales

Creating Group and Adding Group With Samba Share

Use the following command to create a group and change the group for samba share

sudo groupadd sales
sudo chgrp sales /home/sales

creating samba share in Ubuntu 17.04

3. Modifying the /etc/samba/smb.conf file.

Use your favorite file editor and make the following changes in the samba configuration file

#In the Networking section, make the following changes
interfaces 127.0.0.0/8 eth0 192.168.153.0/24
bind interfaces only = yes
#In the same file, scroll-down to the end and add the following settings:
[sales]
    path = /home/sales
    writable = yes
    create mode = 0770
    directory mode = 0770
    guest ok = yes
    valid users = @sales

Configure Samba in Ubuntu Linux 17.04

Save the file and use the testparm command to check the syntax of smb.conf file.

sudo testparm

4. Adding and Enabling Samba User

Now, create a Samba user named smbuser1 and add it to the sales group.

sudo useradd smbuser1
sudo smbpasswd -d smbuser1
sudo usermod –G sales smbuser1

Creating samba user in Linux

To enable samba user, use the following command.

sudo smbpasswd –e smbuser1

5. Enabling and Restarting Samba Service

Use the following commands to enable and restart the samba service in Ubuntu Linux

sudo systemctl restart smbd
sudo systemctl status smbd

Starting Samba service in Ubuntu Linux

We assume that you have allowed the appropriate ports in the firewall. If required, for the testing purpose, you can disable the firewall and SELinux. However, in the production network, you must have to set the appropriate firewall rules and SELinux settings.

Now, you are ready to access samba share. Move on to Windows system and type \\samba-server-ip\sambashare in the Run dialog box. Alternatively, you can also mount the samba share as a network drive as shown in the following figure. Use the smbuser1 credential to access the samba share in Windows system.

Connect samba share from windows system

Now, you should be able to access the samba shared data from the Windows system. If you get stuck anywhere, please write to us in the comment box. Please also share and like the tutorial if it helped you.

  • Also read: Configure NFS in Ubuntu Linux

May 14, 2017 by VCEWin

How To Configure NFS In Ubuntu Linux 17.04

NFS stands for Network File System that is a file service used to allow file sharing between Linux based systems. NFS is a file-level sharing protocol. It means you can mount and access shared data using NFS, but you cannot use NFS to create and format disk partitions. In this tutorial, we will explain how to configure NFS in Ubuntu 17.04. The latest version of NFS is NFSv4. Typically NFS is used for Linux based systems but it can also be now configured between Windows systems.

Recommended articles:

  • How to configure and use NFS in Windows systems.
  • How to configure DHCP In Ubuntu 17.04
  • How to configure DNS in Ubuntu 17.04

For this tutorial, we will create a shared folder on a Ubuntu server and then will mount it on a Ubuntu client machine. In order to configure NFS in Ubuntu 17.04, you need to perform the following steps:

  1. Install the required packages on Ubuntu server.
  2. Modify the configuration file.
  3. Adding the shared directories.
  4. Enabling and starting NFS service
  5. Mounting NFS share on the client machine.

Installing NFS Packages in Ubuntu

The following command is used to install the NFS package in Ubuntu Linux.

sudo apt install nfs-kernel-server

Install NFS Packages in Ubuntu Linux 17.04

Configure NFS Options

Once you have installed the NFS packages, next, you need to update your domain name in the NFS configuration file. For this, you need to execute the following command.

sudo vi /etc/idmapd.conf

In the above file, find the Domain option and replace it with your domain name as shown in the following figure. However, this is an optional step.

Configure NFS Options in Ubuntu Linux

Configure NFS Shared Options

Now, you need to specify the following NFS server settings in the /etc/exports file.

  • Share directories
  • Allowed network or hosts
  • Access permissions and options

To specify the NFS configuration options, edit the /etc/exports file. The following syntax shows the basic options used with NFS protocol in Ubuntu and other Linux variants.

<shared directory> <allowed clients> <access permissions>

Let’s have a look at few of the NFS examples:

  • Share directories: /shareddata
  • Allowed network or hosts: 10.0.0.0/8
  • Access options: read and write with root squash

In order to configure NFS as per the above-mentioned option, the /etc/exports file should look like as follows:

/shareddata 10.0.0.0/8 (rw,no_root_squash)

Let’s have a look at another example:

  • Share directories: /shareddata
  • Allowed network or hosts: All networks
  • Access options: read-only with root squash

The /etc/exports file should look like as follows:

/shareddata *.* (ro,no_root_squash)

If you are interested in learning more options about NFS configuration, you can read the NFS manual reference file by executing the following command:

man exports

Enabling and Starting NFS Service

Once you have set the desired shared directory with the desired access permissions and NFS options, next you need to enable and start the NFS service.

sudo systemctl enable nfs-server
sudo systemctl restart nfs-server
sudo systemctl status nfs-server

Ensure that the NFS service is running properly as shown in the following figure.

Starting NFS Service In Ubuntu Linux

Listing NFS Shares

Make sure that the NFS shares are listed by using the sudo exportfs command as shown in the following figure.

Configure NFS In Ubuntu Linux

NFS Ports and Firewall Configuration

It is always recommended to check that the NFS TCP and UDP ports are listening. If your server is behind the Firewall, you will need to allow the following ports:

  1. TCP and UDP ports 2049
  2. TCP and UDP ports 111
  3. TCP and UDP ports 1110

NFS Port Numbers

We assume that the above ports are allowed between NFS server and NFS clients.

Mounting NFS Share on NFS Client

Now, you all set to mount and use the NFS shared data and directory on the NFS client.

Install the NFS package on Client

Typically, you do not need to install the NFS client packages, but if required, you can install using the following command.

sudo apt install nfs-common

Move on to NFS client and execute the following command to list down the NFS shares.

sudo showmount -e <nfs-server-ip>

NFS Persistent Mounting (Permanent Mount)

You can mount the NFS shares temporary using the mount command. However, once you will your machine, you would need to mount it again. For the permanent NFS mounting, you need to update the file system table file that is /etc/fstab. Edit the /etc/fstab file and mount the NFS share using the following syntax.

<nfs-server-ip>:<nfs-shared-directory> <mount-point> <protocol> defaults 0 0

For example, to mount the shareddata directory on the /NFSData mount point, (assuming that your server IP address is 10.0.0.100) you will have to add the following line at the end of the /etc/fstab file.

10.0.0.100:/shareddata /NFSData nfs defaults 0 0

NFS Permanent Mount in Linux Ubuntu

Save the /etc/fstab file and execute the following command to update the file system table.

sudo mount –a

Go to the NFS mounted directory and use it as your local directory.

In this tutorial, we have explained how to configure NFS in Ubuntu latest version that is Ubuntu 17.04. However, the same steps can also be used to configure NFS in the earlier version of Ubuntu such as Ubuntu 16.04 and Ubuntu 14.04.

  • « Previous Page
  • 1
  • 2
  • 3
  • 4
  • …
  • 6
  • Next Page »

Windows Server 2016 – Lab Manual Guide

The Best CCNA Self Study Guide

Like Us

AWS Cloud Self Learning Guide

Recent Posts

  • How To Scan EC2 Instances Using Amazon Inspector
  • Creating and Using AWS NAT Gateways – Step By Step
  • How To Create and Use AWS Internet Gateways
  • How To Create and Manage AWS Virtual Private Cloud (VPC)
  • Step By Step Guide To Create AWS Account Without Credit Card

Newsletter

  • Contact Us
  • Terms and Conditions
  • About Us

Copyright © ‘2019’ · VCEWin ·

Pretty Chic Theme By: Pretty Darn Cute Design