'Disable SSHAgent 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 1:[1]
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.
Solution 2:[2]
I know this is an old question, but the correct answer to "How can I tell ssh with a command line option to not use the SSH-Agent?" hasn't been given yet:
- use the
-o IdentityAgent=none
option
From https://man7.org/linux/man-pages/man5/ssh_config.5.html (emphasis added):
IdentityAgent
Specifies the UNIX-domain socket used to communicate with the authentication agent.
This option overrides the SSH_AUTH_SOCK environment variable and can be used to select a specific agent. Setting the socket name to none disables the use of an authentication agent. ...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | sorin |
Solution 2 | Michael Burr |