The Wayback Machine - https://web.archive.org/web/20240707042249/https://www.geeksforgeeks.org/how-to-use-hydra-to-brute-force-ssh-connections/
Open In App

How to use Hydra to Brute-Force SSH Connections?

Last Updated : 02 Aug, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Let’s explore using Hydra to brute-force SSH. One of the most popular tools in a hacker’s toolbox is Hydra. It is a great tool for brute force attacks, and you can use it both as a blue team to audit and test ssh passwords against popular password lists like rockyou.txt and crack station wordlists and as a red team to break into computers. 

What is SSH (Secure Shell)?

The SSH Protocol uses the access credential SSH (Secure Shell). To put it another way, it is a cryptographic network protocol used to send encrypted data across a network. Without having to remember or type in your password for every system that needs to log in remotely from another system to a server, you can connect to one or more servers. 

 

What is Hydra?

Hydra is an open-source tool that allows us to perform various kinds of brute force attacks using wordlists. It comes by default with all Pentesting Distros like Kali Linux. Hydra is a parallelized login cracker that can attack many different protocols. It is already installed in Kali Linux and is used to launch dictionary or brute-force attacks against username and password to several services, including MS-SQL, FTP, ssh, telnet, etc. 

Installation and Usage of Hydra tool 

Installation:

Execute the below command in the terminal to install the hydra tool using the apt package manager.  

sudo apt install hydra 

 

Usage:

Example 1: Bruteforcing Both Usernames And Passwords

Type the below command on the terminal and hit Enter.

hydra -L user.txt -P pass.txt 192.168.29.135 ssh -t 4
  • -l specifies a username during a brute force attack.
  • -L specifies a username wordlist to be used during a brute force attack.
  • -p specifies a password during a brute force attack.
  • -P specifies a password wordlist to use during a brute force attack.
  • -t set to 4, which sets the number of parallel tasks (threads) to run.
     

 

From the above screenshot we that the username and password were found. But in the real world, you need thousands, millions and even billions of trials to crack the password.

Example 2: Bruteforcing Passwords 

Type the below command on the terminal and hit Enter.

hydra -l msfadmin -P pass.txt 192.168.29.135 ssh -t 4

Here, we are only brute-forcing passwords on the target server.

 

Example 3: Bruteforcing Username

Type the below command on the terminal and hit Enter.

 hydra -L user.txt -p msfadmin 192.168.29.135 ssh -t 4

In the above example, we were a brute-forcing only passwords, so in this example, we are brute-forcing only usernames on the target server.

 

Some Special Flags: 

Example 1: Change The Number Of Threads

Type the below command on the terminal and hit Enter.

 hydra -L user.txt -P pass.txt 192.168.29.229 ssh -t 5

Here we are changing the Thread Number to 5 and finding the correct username and password. The default thread of Hydra use is 16. We can change the value with the tag -t.

 

Example 2: Change The Port Number

Type the below command on the terminal and hit Enter.

hydra -s 22 -L user.txt -P pass.txt 192.168.29.229 ssh -t 5

Here we are adding the port number of the ssh server as 22 and we have also got the correct password ‘msfadmin’ and username ‘msfadmin’.

 

Example 3: Brute Forcing A List Of IPs

Type the below command on the terminal and hit Enter.

 hydra -L user.txt -P pass.txt -M ip.txt ssh -t 4

Here, along with brute-forcing usernames and passwords, we are also a brute-forcing list of IP addresses that contain more than one target server address.

 

Example 4: Miscellaneous

Type the below command on the terminal and hit Enter.

hydra -l msfadmin -P pass.txt 192.168.29.229 -V -e nsr ssh

For Enable Verbose Mode in Hydra, We can use -V. But user/system admins leave some passwords that need to be accounted for beyond the scope of our wordlists which can be included with the -e flag. Here you can see a command ‘nsr‘ where ‘n’ stands for null,‘s‘ stands for same, ‘r’ tries the reversed username as a potential password

 

Example 5: -V (Verbose Mode)

Type the below command on the terminal and hit Enter.

hydra -s 22 -L user.txt -P pass.txt 192.168.29.229 ssh -V

The verbose mode in hydra is used for checking in-depth and getting the output results in a more detailed manner. So for this detailed output retrieval, the -V flag is used.

 

Example 6: -e nsr flag example

Type the below command on the terminal and hit Enter.

hydra -L user.txt -P pass.txt 192.168.29.229 -e nsr ssh

Sometimes user/system admins leave some passwords that need to be accounted for beyond the scope of our wordlists which can be included with the -e flag. Here you can see a command ‘nsr‘ where ‘n’ stands for null, ‘s‘ stands for same, and ‘r’ tries the reversed username as a potential password. We got the output msfadmin username and password is msfadmin.

 

Example 7: -s flag example 

Note: Example of Changing port number command is the same for this example

Type the below command on the terminal and hit Enter.

hydra -s 22 -L user.txt -P pass.txt 192.168.29.229 ssh -t 5

With flag -s we specify the port number here is port number is 22 and we are using it and got the output is a username is msfadmin and password is msfadmin.

 

Example 8: -h flag (To know more usage of Hydra )

Type This Command And Hit Enter:

hydra -h

-h flag is used to display the help menu of the hydra tool for a better understanding of the tool.

 

Hydra can be a pretty powerful tool when you want to brute-force ssh connections and can be coupled with several other flags to customize your attack. However, this must not be exploited to poke around with stuff you are not meant to and the users alone are accountable for their actions.


Previous Article
Next Article

Similar Reads

How to Install and Use Hydra in Linux?
Weak passwords are still a big problem in security, nowadays guessing passwords and cracking algorithms is becoming easy and brute-forcing is a major kind of attack in the boom. A general rule for making a strong password is using a combination that is long(more than 8 letters) with capitals, symbols, and numeric's. To crack passwords a great tool
3 min read
How do I use SSH to connect to a remote server in Linux | ssh Command
Secure Shell, commonly known as SSH, is like a super-secure way to talk to faraway computers, called servers. It's like a secret tunnel on the internet that keeps your conversations safe and private. Imagine you're sending a letter, and instead of sending it openly, you put it in a magic envelope that only you and the person you're sending it to ca
8 min read
Crack Web Based Login Page With Hydra in Kali Linux
Hydra is one of the most powerful open-source password-cracking programs available in Kali Linux. One of the most popular and open-source tools among hackers and penetration testers, it is used for dictionary attacks and brute-forcing. It can brute-force by sending multiple login requests very rapidly to a variety of network protocols, services, we
6 min read
How To Generate SSH Key With ssh-keygen In Linux?
Secure Shell(SSH) is a cryptographic network protocol used for operating remote services securely. It is used for remote operation of devices on secure channels using a client-server architecture that generally operates on Port 22. SSH is the successor of Telnet. SSH uses public and private keys to validate and authenticate users. ssh-keygen is use
4 min read
CrawlBox - Easy Way to Brute-force Web Directory
Directory brute force is used to find hidden and often forgotten directories on a site to try to compromise. Some various automated tools and scripts retrieve the status of the directory which is brute-forced from custom wordlists. CrawlBox tool is a Python language-based tool, which is the command line in use. CrawlBox tool is an advanced tool tha
4 min read
W3brute - Automatic Web Application Brute Force Attack Tool
Brute-Forcing is an automated process through which Usernames, Passwords can be detected by querying the possible credentials on the target domain login pages. We can also brute-force hidden files and directories on the target server by specifying the possible word list which contains the phrases that will be tested on the domain. This process save
3 min read
SubBrute – Tool For Subdomain Brute Force
SubBrute is a free and open-source tool available on GitHub. SubBrute uses DNS Scan for finding subdomains of the target domain. This feature of SubBrute provides an extra layer of anonymity for security researchers. This tool is free means you can download and use this tool free of cost. SubBrute is used for reconnaissance of subdomains. SubBrute
2 min read
Brutex - Open Source Tool for Brute Force Automation
Brutex is a free and open-source tool available on GitHub. This tool is basically made to make the work of penetration tester easier. This tool is a package of three different tools which are Nmap, Hydra, DNSenum. Once you start scanning your target using brutex tool the tool will start scanning using Nmap and after scanning, brutex will force all
1 min read
Brutespray - Port Scanning and Automated Brute Force Tool
Brute-Forcing is the technique of matching the credentials like Usernames, Passwords, OTPs for unauthenticated access to the target domain. The list of words are been tested against the target to get the exact credentials. All this process is done through automated tools. Brutespray is an automated tool that is used to perform brute-forcing for eve
3 min read
0xWPBF – WordPress Users Enumerate and Brute Force Attack
WordPress is a popular CMS which is been used by many web-based applications for providing the service to the end-users. WordPress CMS contains the version which is been updated due to resolved bugs and CVEs. The outdated version can make the Web-based Application vulnerable to cyber threats. Identification of Versions and detection of hidden files
2 min read
Article Tags :