sshssh-agent

Disable SSH agent with command line option


How can I tell ssh with a command line option to not use the SSH agent?

ssh -a does something different. It does not forward the agent, but uses it.

I read the man page, and could not find a solution.

Unsetting SSH_AUTH_SOCK would work, but a command line option would be much better in my context.


Solution

  • You can force ssh to use anything else than a SSH key to authenticate (e.g. password) with

    ssh -o PubkeyAuthentication=no ...
    

    this way of course the agent will be ineffective. If you want to use a key, you can also specify it explicitly and ssh will only use that key and not all that are in the agent:

    ssh -i path/to/id_rsa -o IdentitiesOnly=yes -F /dev/null ...
    

    You mentioned SSH_AUTH_SOCK. You can unset it just in the context of your ssh command like this:

    SSH_AUTH_SOCK= ssh ...
    

    Note the space after SSH_AUTH_SOCK=. This way your are sure that the agent is not used while at the same time not modifying your working environment.