Skip to content

Check for Existing SSH Keys

This guide will help you check if you have existing SSH keys on your machine.

Make sure you choose the correct tabs based on your operating system and development environment.

SSHD Running

Before checking for existing SSH keys, make sure the SSH daemon (sshd) is running. If it is not running, you will not be able to load the keys into the agent.

If you followed the setup guide to install OpenSSH, it should already be running. If you did not install OpenSSH because it is already installed, make sure it is running by executing the following command. You only have to run this command once.

Run the following command in Windows PowerShell as an Administrator to set the sshd service to start automatically.

Set SSHD to Start Automatically
# Set the sshd service to be started automatically.
Get-Service -Name sshd | Set-Service -StartupType Automatic
Start SSHD Service
# Start the sshd service.
Start-Service sshd

1. Checking File Path for Existing SSH Keys

Open Windows PowerShell as an Administrator.

Run the following command to check for existing SSH keys:

Check for Existing SSH Keys
Get-ChildItem -Path ~/.ssh -Filter "id_*"

If you see any files with names like id_rsa, id_rsa.pub, id_dsa, id_dsa.pub, id_ecdsa, id_ecdsa.pub, id_ed25519, or id_ed25519.pub, then you already have SSH keys, but they may not be loaded into the SSH agent. Complete the next step to check if the agent is running and has the keys loaded.

2. Checking SSH Agent for Existing Keys

Run the following command to check if the SSH agent is running:

Check if SSH Agent is Running
Get-Service -Name ssh-agent

If the service is running, you should see output similar to the following:

Status   Name               DisplayName
------   ----               -----------
Running  ssh-agent          OpenSSH Authentication Agent

If the service is not running, you can start it with the following command:

Start SSH Agent
Start-Service -Name ssh-agent

After the SSH agent is started, run the following command to check if it has any keys loaded:

Check SSH Agent Keys
ssh-add -l

If you see any keys listed, then you already have keys loaded in the agent. If you have key files but no keys loaded into the agent, refer to Loading SSH Keys into the Agent.

1. Checking File Path for Existing SSH Keys

Open Terminal.

Run the following command to check for existing SSH keys:

Check for Existing SSH Keys
ls -al ~/.ssh

If you see any files with names like id_rsa, id_rsa.pub, id_dsa, id_dsa.pub, id_ecdsa, id_ecdsa.pub, id_ed25519, or id_ed25519.pub, then you already have SSH keys, but they may not be loaded into the SSH agent. Complete the next step to check if the agent is running and has the keys loaded.

2. Checking SSH Agent for Existing Keys

Run the following command to check if the SSH agent is running:

Check if SSH Agent is Running
echo "$SSH_AUTH_SOCK"

If the agent is running, you should see an output path. If the SSH Agent is not running, you should see no output or blank output.

If the agent is not running, you can start it with the following command:

Start SSH Agent
eval "$(ssh-agent -s)"

After the SSH agent is started, run the following command to check if it has any keys loaded:

Check SSH Agent Keys
ssh-add -l

If you see any keys listed, then you already have keys loaded in the agent. If you have key files but no keys loaded into the agent, refer to Loading SSH Keys into the Agent.

1. Checking File Path for Existing SSH Keys

Open your Bash terminal or shell.

Run the following command to check for existing SSH keys:

Check for Existing SSH Keys
ls -al ~/.ssh

If you see any files with names like id_rsa, id_rsa.pub, id_dsa, id_dsa.pub, id_ecdsa, id_ecdsa.pub, id_ed25519, or id_ed25519.pub, then you already have SSH keys, but they may not be loaded into the SSH agent. Complete the next step to check if the agent is running and has the keys loaded.

2. Checking SSH Agent for Existing Keys

Run the following command to check if the SSH agent is running:

Check if SSH Agent is Running
echo "$SSH_AUTH_SOCK"

If the agent is running, you should see an output path. If the SSH Agent is not running, you should see no output or blank output.

If the agent is not running, you can start it with the following command:

Start SSH Agent
eval "$(ssh-agent -s)"

After the SSH agent is started, run the following command to check if it has any keys loaded:

Check SSH Agent Keys
ssh-add -l

If you see any keys listed, then you already have keys loaded in the agent. If you have key files but no keys loaded into the agent, refer to Loading SSH Keys into the Agent.