Summary
In my previous post, I explained in detail, how to setup Kali Linux on a Hyper-V platform hosted on Windows 11. In this post we will set up Kali Linux on the AWS EC2 platform, and we will also configure a GUI for us to access. The following will be covered.
- Spin up an EC2 instance with a Kali linux image from AWS Marketplace.
- Once the EC2 instance is available install GUI tools on it.
- Change hostname.
- Change timezone.
- Install MS-Edge browser.
- Install Homebrew and Github CLI.
- Install VSCode and some common extensions.
[1] Spin up an EC2 instance
- 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.
- 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
- 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.
- Review and launch the instance.
[2] Install GUI tools via ssh
- Once the EC2 instance is available use your key-pair to ssh to it.
- Once you are in run the following commands to update your OS. You will get a couple of interactive prompts along the way while your packages are being updated. If you do not understand an of them leave them unchanged.
# See the man page for apt-get to understand each command better.
# https://linux.die.net/man/8/apt-get
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
- Install the GUI tools using the following commands
sudo apt-get install -y kali-desktop-xfce xorgxrdp xrdp
sudo systemctl enable xrdp --now
- You can check the xrdp status using the following command, it should be in running state.
┌──(kali㉿kali)-[~]
└─$ sudo service xrdp status
● xrdp.service - xrdp daemon
Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2022-01-17 08:52:38 UTC; 5min ago
Docs: man:xrdp(8)
man:xrdp.ini(5)
Process: 66628 ExecStartPre=/bin/sh /usr/share/xrdp/socksetup (code=exited, status=0/SUCCESS)
Process: 66636 ExecStart=/usr/sbin/xrdp $XRDP_OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 66637 (xrdp)
Tasks: 1 (limit: 9090)
Memory: 904.0K
CPU: 10ms
CGroup: /system.slice/xrdp.service
└─66637 /usr/sbin/xrdp
- Add user for RDP
# See man page for useradd
# https://linux.die.net/man/8/useradd
# Replace <Username> with the user login
sudo useradd -m <UserName>
# Set the user shell for the user <UserName>
# https://linux.die.net/man/1/chsh
sudo chsh -s /bin/zsh <UserName>
- Set a new password for your RDP user
┌──(kali㉿kali)-[~]
└─$ sudo passwd sysadmin 1 ⨯
New password:
Retype new password:
passwd: password updated successfully
- Add the new user to the sudo group
sudo useradd -a -G sudo <UserName>
- Download a RDP client like RDC Man and use your EC2 instance IP address / DNS name as configured for your VPC to access the EC2 instance.
[3] Set hostname
- Edit the /etc/hosts file using an editor. Add the hostname as in the image where "hostname" is the name of your choice. Use the same name in the next command also.
- Now use the below command to set the hostname using hostnamectl. Use the same name set in /etc/hosts file above.
# Make sure <hostname> used here is same as the one used in /etc/hosts file. Else sudo might break.
sudo hostnamectl hostname <hostname>
- You can see the hostname you set using hostnamectl command.
┌──(kali㉿kali)-[~]
└─$ sudo hostnamectl
Static hostname: ll-kali-02
Icon name: computer-vm
Chassis: vm
[4] Set timezone
- You can set the timezone using the timedatectl command where "timezone" is the one of your choice.
# See man for timedatectl
# Example used is Asia/Kolkata timezone
sudo timedatectl set-timezone Asia/Kolkata
- Use the timedatectl command to see your timezone.
┌──(kali㉿kali)-[~]
└─$ timedatectl
Local time: Mon 2022-01-17 15:40:02 IST
Universal time: Mon 2022-01-17 10:10:02 UTC
RTC time: Mon 2022-01-17 10:10:02
Time zone: Asia/Kolkata (IST, +0530)
[5] Install Microsoft Edge Browser
- Use the steps mentioned in this link.
## Installing the stable version
## Setup
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-beta.list'
sudo rm microsoft.gpg
## Install
sudo apt update
## Install the stable update
sudo apt install microsoft-edge-stable
[6] Install Homebrew and GitHub CLI
- Use the steps mentioned in this link to install homebrew on your OS.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Once this is installed follow the onscreen instructions to add brew to your current and shell profile.
- Install Github CLI
brew install gh
[7] Install Visual Studio Code
Download the .deb file for VsCode from the following link.
Install VsCode using the following command
# Once you download the .deb file from the above link use the following command to install VsCode
sudo apt install ./<file>.deb
[7.1] Install common extensions in VsCode
- Use the following code to install some of the common extensions using VsCode CLI.
code --install-extension amazonwebservices.aws-toolkit-vscode --force
code --install-extension christian-kohler.path-intellisense --force
code --install-extension CoenraadS.bracket-pair-colorizer --force
code --install-extension DavidAnson.vscode-markdownlint --force
code --install-extension eamodio.gitlens --force
code --install-extension esbenp.prettier-vscode --force
code --install-extension GitHub.vscode-pull-request-github --force
code --install-extension ms-python.python --force
code --install-extension ms-python.vscode-pylance --force
code --install-extension ms-toolsai.jupyter --force
code --install-extension ms-toolsai.jupyter-keymap --force
code --install-extension ms-toolsai.jupyter-renderers --force
code --install-extension VisualStudioExptTeam.vscodeintellicode --force
code --install-extension zhuangtongfa.material-theme --force
Top comments (2)
did all steps but where do I access the gui
I would like to point out that there was a mistake.
x : sudo useradd -a -G sudo
o : sudo usermod -a -G sudo