In this final step, we'll verify that your SSH server is properly configured and accessible. This is crucial because Hydra (the password cracking tool we'll use in later labs) requires a functional SSH service to test against. We'll perform several checks to ensure everything works as expected.
-
First, let's check if the SSH service is actually running. Services can sometimes fail to start or crash unexpectedly, so this is our first sanity check:
sudo service ssh status
The output should clearly show "active (running)". If it doesn't, we'd need to troubleshoot the service before proceeding.
-
Now we'll test local SSH access using one of the test accounts we created earlier. This simulates how Hydra will attempt to connect:
ssh testuser1@localhost
When prompted, enter the password "password123" (the one we set up earlier). After successfully logging in, type exit
to return to your main session. This confirms basic password authentication works.
-
Let's specifically test password authentication (as Hydra primarily brute-forces passwords). We'll force SSH to use password auth and intentionally provide a wrong password:
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no testuser1@localhost
Enter any incorrect password when prompted. The server should reject the connection, which is the expected behavior we want to see.
-
Next, we'll verify the SSH server is listening on the correct network interface and port. This ensures remote connections (like from Hydra) can reach the service:
sudo netstat -tulnp | grep sshd
You should see sshd listening on 0.0.0.0:22, meaning it accepts connections from any network interface on the standard SSH port (22).
-
Finally, let's examine the authentication logs to see our test attempts recorded. Logs are valuable for troubleshooting and understanding what's happening behind the scenes:
sudo tail -n 10 /var/log/auth.log
Look for entries showing your successful login (step 2) and failed attempt (step 3). These logs will also be important when analyzing Hydra's attack attempts later.