Page cover

22/tcp - SSH

General Information

Name

Secure Shell Socket

Service

SSH (Secure Shell Socket) is a network protocol that gives users, a secure way to access a computer over an unsecure network.

Notes

Ability to login into a machine remotely. SSH is the encrypted version of telnet

Connection

Client

# Credentials
ssh USERNAME@IP
# ID RSA
ssh -i id_rsa_FILE USERNAME@IP

Recon Checkklist

Brute Force (Hydra)

SSH Audit

ssh-audit tool

Get/Put Files

Scripts

Nmap

Script Name
Description
Usage

ssh-brute

Attempts password guessing using brute force. The userdb file need to contain the username or list of usernames.

nmap -p 22 --script ssh-brute <target> —script-args userdb=<dict>

ssh-hostkey

Displays the SSH server's public key for comparison.

nmap -p 22 --script ssh-hostkey --script-args ssh_hostkey=full <target>

ssh2-enum-algos

Enumerates algorithms supported by the SSH server.

nmap -p 22 --script ssh2-enum-algos <target>

ssh-auth-methods

Enumerate authentication methods for a specific user

nmap -p 22 —script ssh-auth-methods —script-args=”ssh.user=<username>” <target>

ssh-run

Run commands

nmap -p 22 —script ssh-run —script-args=”ssh-run.cmd=<command>,ssh-run.uslername=<user>,ssh-run.password=<pass>”

circle-info
  1. List all available nmap scripts :

nmap --script-help="ssh-*"

ls /usr/share/nmap/scripts/ssh-*.nse

  1. We can run all the available nmap scripts with:

nmap --script ssh-* -p 22 IP

Metasploit

Script Name
Description
Parameters

auxiliary/scanner/ssh/ssh_version

Gets the version of the SSH server.

RHOSTS, THREADS, USER_AS_PASS

auxiliary/scanner/ssh/ssh_login

Attempts brute-force authentication on an SSH server.

RHOSTS, USER_FILE, PASS_FILE, VERBOSE, STOP_ON_SUCCESS

auxiliary/scanner/ssh/ssh_enumusers

Enumerates valid users on an SSH server.

RHOSTS, USER_AS_PASS, THREADS

Last updated