Configuring AWS EFS to work with Kali Linux running on AWS EC2
Tags: aws, kalilinux, linux, efs
Published: 2022-01-24 02:58:06

![Kali linux with AWS EFS mounted](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v40wgaee1qv6por3vapm.png)

## Summary

In this post I would walk through the following:

* [Creating an Amazon EFS file system](#Al1)
* [Configuring an Amazon EFS file system to work with Kali Linux running on AWS EC2](#Al2)
    * [Pre-requisites](#Al21)
    * [Mount using AWS efs-mount-helper](#Al22)
* [Attaching an EFS file system while creating an EC2 instance](#Al3)

## [1] Create your own Amazon EFS File System <a name="Al1"></a>

* Log in to your AWS Account.
* Go to your region of choice where your EC2 instance is hosted. If you do not have an EC2 instance running Kali linux you can follow my previous post to set one up. Link to post [here](https://dev.to/soumyajyotibiswas/install-and-configure-gui-for-kali-linux-on-aws-ec2-2jkg).
* Go to the service **EFS** and click on **Create file system**.
![Creating AWS EFS File System via console, image 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fmiew8cn5qkh87r27n21.png)
* Provide a name for your efs file system (note its optional), select the VPC where your EC2 instance is running already or one where you plan to spin one up, and select the availability of your EFS. Regional is recommended option for availability for redundant data storage. Related AWS documentation for creating EFS. [link](https://docs.aws.amazon.com/efs/latest/ug/creating-using-create-fs.html).
![Creating AWS EFS File System via console, image 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v3wg7v7irtbqla23hiqq.png)
* Once your EFS file system is created, you will see an available state displayed to you in the EFS console.
![Creating AWS EFS File System via console, image 3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ffotydoaoqpy13yg36q.png)
* Create a [securtiy group](https://docs.aws.amazon.com/efs/latest/ug/accessing-fs-create-security-groups.html) to allow NFS access.
* Create mount targets as in [link](https://docs.aws.amazon.com/efs/latest/ug/accessing-fs.html). You can see them in the network tab of your efs file system.
![Creating AWS EFS File System via console, image 4](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7gozsycwni0rksj0xtx8.png)

## [2] Configuring an Amazon EFS file system to work with Kali Linux running on AWS EC2 <a name="Al2"></a>

### [2.1.] Pre-requisites <a name="Al21"></a>

* Install **amazon-efs-utils** debian package. AWS documentation link [here](https://docs.aws.amazon.com/efs/latest/ug/installing-amazon-efs-utils.html). Though the efs-utils documentation does not call out Kali linux explicitly, the debian package does work as you will see through this tutorial.

```bash
sudo apt-get -y update
sudo apt-get -y install git binutils
git clone https://github.com/aws/efs-utils
cd /path/efs-utils
./build-deb.sh
sudo apt-get -y install ./build/amazon-efs-utils*deb
```

* The connecting EC2 instance must be in a virtual private cloud (VPC) based on the Amazon VPC service. It also must be configured to use the DNS server provided by AWS. For information about the Amazon DNS server, see [DHCP Options Sets](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_DHCP_Options.html) in the Amazon VPC User Guide.

* The VPC of the connecting EC2 instance must have DNS hostnames enabled. For more information, see [Viewing DNS Hostnames for Your EC2 Instance](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-dns.html#vpc-dns-viewing) in the Amazon VPC User Guide.

### [2.2.] Mount the file system using efs-mount-helper <a name="Al22"></a>

* Create a mount directory.

```bash
mkdir ~/efs-mount-point
```

* Mount your directory with tls encryption in transit. See AWS documentation [here](https://docs.aws.amazon.com/efs/latest/ug/efs-mount-helper.html).

```bash
sudo mount -t efs -o tls fs-<your fs id> ~/efs-mount-point/
```

* You can verify this using the **mount** command. You will see an output line from the **mount** command as

```text
127.0.0.1:/ on /home/<your user>/efs-mount-point type nfs4
```

* To auto-mount using **/etc/fstab** you can first create an access point for your user see [link](https://docs.aws.amazon.com/efs/latest/ug/efs-access-points.html#enforce-identity-access-points). Once you have created an access point, you can use the following in the **/etc/fstab** file.

```bash
file-system-id efs-mount-point efs _netdev,tls,accesspoint=access-point-id 0 0
```

* Configure users, groups and permissions as defined in this [link](https://docs.aws.amazon.com/efs/latest/ug/accessing-fs-nfs-permissions.html), to create an access/permissions hierarchy for using your efs file system.

## [3] Attach an EFS file system while creating an instance <a name="Al3"></a>

* You can refer to my [post](https://dev.to/soumyajyotibiswas/install-and-configure-gui-for-kali-linux-on-aws-ec2-2jkg) on configuring Kali linux on AWS EC2.
* Log into you AWS account, and choose a region nearest to you. If you do not have an account you can sign up for one for free using this [link](https://aws.amazon.com/free/).
* Go to **EC2** service and click on **Launch Instances**.
* In AMI's seach for the keyword **Kali** and select the image from AWS marketplace as shown in the image below

![Selecting a Kali image from AWS marketplace](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m0uzq105kfo88igyysmw.png)

* Accept the aws marketplace subscription dialog box.
* Add an instance type.
* Select a VPC and the basic networking setup. Add an EBS volume and choose a keypair to associate with you instance.
* Make sure to associate a security group with your instance which has inbound ports 3389 and 22 open.
* In the **configure instance details** page, under **file systems**, choose the **file system** you created in step 1.
![Configuring AWS EFS file system during AWS EC2 launch](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6j8wugnr1ke4csqabhvq.png)
* Review and launch the instance.