« Back to SSH: Frequently Asked Questions

How to disable the usage of the SSH agent

How to disable the usage of the SSH agent?

Define the SSH option IdentityAgentRun with the value 'none' when connecting to a system to disable the usage of the SSH agent.

ssh -o IdentityAgent=none user@hostname

The ssh command can be instructed to avoid using the SSH agent and its known identities with the -o IdentityAgent=none option. This sets the option IdentityAgent to disable the SSH agent.

Command line usage

To use this option on the command line, specify the setting and set it to no.

ssh -oStrictHostKeyChecking=no user@hostname

Usage in configuration file

This setting can also be configured in /etc/ssh_config to define it as its default. An alternative is to define it per host, in the file in your home directory ~/.ssh/config .

To make it a default, define a generic section at the bottom of your config file.

Host *
    # Only use the Identities that are specified with IdentityFile
    IdentitiesOnly yes
    # Define primary key
    IdentityFile /home/%u/.ssh/id_ed25519
    # Disable entities known to ssh-agent
    IdentityAgent none
    # Avoid password authentication
    PasswordAuthentication no

Other questions related to SSH

    Related articles

    Like to learn more? Here is a list of articles within the same category or having similar tags.

    Feedback

    Small picture of Michael Boelen

    This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

    Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution!

    Mastodon icon