How to connect to a Kali Linux EC2 instance using SSH
Prerequisites
- Launch a Kali Linux EC2 instance via AWS.
- Create new key pair and download PEM file when prompted.
- This happens during the instance setup. If you already have another key pair, you can select it from the dropdown.
- Make sure you have access to the key, or you won't be able to SSH into your instance.
Setup
There are three pieces of info requires for SSH-ing in to your instance:
- Username - For Kali Linux, it's
kali
- IP Address - This is the public IP address for your instance
- PEM file - Downloaded during setup
How do I find the instance's public IP address?
To view details for the instance, including its public IP address, start by going to the EC2 console.
-
Under Resources, Click Instances (running)
- You can also click on Instances in the left sidebar
- If there are no instances running and you know you launched it, try switching which region you're in using the dropdown in the top right-hand corner. There's a good chance it was created in a different region.
-
Find the Kali Linux instance in the list
-
Scroll right until you find the column labeled Public IPv4. Copy the value.
SSH into the machine
- Open your terminal
- Make note of where your PEM file is located
- Run the following command with your PEM and IP values:
ssh -i <yourpemfile.pem> kali@<publicIPAddress>
Success! Your shell prompt should now show something like (kali㉿kali)-[~] $
Have fun!
Problems?
My first attempt failed due to a warning message/error like
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/path/to/my/key.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /path/to/my/key.pem
Permission denied (publickey).
To fix this error, update the permissions on your PEM file using chmod
.
$ sudo chmod 600 /path/to/my/key.pem