Skip to main content

SSH-KEY ERROR

 

SSH Agent Forwarding Troubleshooting (Windows → Linux Jump Box)

Problem

Running on the jump box:

ssh-add -l

Error:

Could not open a connection to your authentication agent.

Or on Windows:

ssh-add %USERPROFILE%\.ssh\id_ed25519

Error:

Error connecting to agent: No such file or directory

Root Cause

The local Windows OpenSSH Authentication Agent (ssh-agent) was not running.

Without a running local SSH agent:

  • ssh-add cannot load the private key.

  • ssh -A has no identities to forward.

  • The jump box cannot access the forwarded SSH key.


Troubleshooting Steps

1. Check the SSH Agent status (Windows)

sc query ssh-agent

If the output contains:

STATE : STOPPED

the service must be started.


2. Enable automatic startup

Run Command Prompt as Administrator:

sc config ssh-agent start=auto

3. Start the SSH Agent

net start ssh-agent

Expected:

The OpenSSH Authentication Agent service was started successfully.

4. Add the private key

ssh-add %USERPROFILE%\.ssh\id_ed25519

Expected:

Identity added:

5. Verify locally

ssh-add -l

Expected:

256 SHA256:...

6. Connect with agent forwarding

ssh -A user@jumpbox

7. Verify on the jump box

Check forwarded identities:

ssh-add -l

Or verify the forwarded socket:

echo $SSH_AUTH_SOCK

If a valid socket path is displayed, agent forwarding is active.


Common Errors

Error

Error connecting to agent: No such file or directory

Cause:

  • Local SSH agent is not running.


Error

The agent has no identities.

Cause:

  • SSH agent is running.

  • No private keys have been added.

Fix:

ssh-add %USERPROFILE%\.ssh\id_ed25519

Error

Could not open a connection to your authentication agent.

Cause:

  • Agent forwarding is not working.

  • SSH agent is not running.

  • Remote server does not allow agent forwarding.


Useful Commands

Check service:

sc query ssh-agent

Start service:

net start ssh-agent

Add key:

ssh-add %USERPROFILE%\.ssh\id_ed25519

List identities:

ssh-add -l




Connect with forwarding:

ssh -A user@jumpbox

Verify on Linux:

echo $SSH_AUTH_SOCK
ssh-add -l

Debugging Flow

ssh-add fails on Windows
        │
        ▼
Check ssh-agent service
        │
        ├── Stopped
        │      │
        │      ▼
        │  Start ssh-agent
        │      │
        ▼      ▼
Add private key (ssh-add)
        │
        ▼
Verify (ssh-add -l)
        │
        ▼
SSH with -A
        │
        ▼
On jump box:
echo $SSH_AUTH_SOCK
        │
        ├── Empty
        │      └── Agent forwarding not working
        │
        └── Path exists
               │
               ▼
         ssh-add -l
               │
               ▼
         Forwarding successful

Comments

Popular posts from this blog

MSRPC (Microsoft Remote Procedure Call) Pentesting - Port 135

  It is also known as a function call or a subroutine call. Default ports are 135, 593. Enumeration nmap --script msrpc-enum -p 135 <target-ip> RPC Endpoints To enumerate RPC endpoints, use impacket-rpcdump. impacket-rpcdump -port 135 <target-ip> | grep -E 'MS-EFSRPC|MS-RPRN|MS-PAR' MS-EFSRPC: It might be vulnerable to PetitPotam. MS-RPRN, MS-PAR: It might be vulnerable to PrintNightmare. Metasploit msfconsole msf> use auxiliary/scanner/dcerpc/endpoint_mapper msf> use auxiliary/scanner/dcerpc/hidden msf> use auxiliary/scanner/dcerpc/management msf> use auxiliary/scanner/dcerpc/tcp_dcerpc_auditor Connect # Anonymous logon rpcclient -N -U "" <target-ip> rpcclient -N -U "" -p 593 <target-ip> rpcclient -N -U "" dc.example.local # Specify username # -W: Workgroup # -N: No password rpcclient -U username <target-ip> rpcclient -W WORKGROUP -U username <target-ip> rpcclient -U username -N <target-ip...

Thread Modelling Cheatsheet: Know Your Weaknesses Before Attackers Do!

Threat Modelling Part - 1 What is Threat Modelling?      Threat modelling is the process of identifying, assessing, and mitigating potential security threats before they happen. It helps teams anticipate how systems can be attacked and build defences proactively , not reactively. Key Concepts Threat: Something (like a hacker or malware) that could exploit a weakness. Vulnerability: A flaw in your system that can be exploited. Risk: The chance that a threat will exploit a vulnerability to cause damage. Analogy : Threat = Burglar Vulnerability = Unlocked door Risk = Getting robbed because the door is open in a bad neighborhood  Threat Modelling Process (High-Level) Define the Scope – What systems/apps are you evaluating? Identify Assets – What needs protection? (e.g. data, services) Identify Threats – Think like an attacker. What could go wrong? Analyze Vulnerabilities – What weaknesses exist? Prioritize Ri...

PostgreSQL - Port 5432

  PostgreSQL, also known as Postgres, is a powerful open-source object-relational database system. It has earned a strong reputation for its proven architecture, reliability, data integrity, robust feature set, and extensibility. Identify PostgreSQL nmap -sV -p 5432 <target-host> nmap Scanning nmap -sC -sV --script vuln,vulners --script-args mincvss=7.0 -p5432,5433 -Pn 10.10.10.10 #make sure to check for vulnerable versions nmap -sV -p 5432 <target-host> Exploiting Known Vulnerabilities searchsploit postgresql <version> Enumerating Databases and Tables List all databases \l Switch to a database \c <database_name> List tables in the current database: \dt Extract data from a specific table: SELECT * FROM <table_name>; Dumping Hashes SELECT usename, passwd FROM pg_shadow; Accessing File System COPY (SELECT * FROM sensitive_table) TO '/tmp/sensitive_data.txt'; Bruteforcing Postgres Creds #Using Metasploit use auxiliary/scanner/postgr...