Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 505
guettli Avatar asked Oct 08 '14 13:10

guettli


People also ask

How do I stop an ssh-agent in Windows?

Shutting Down the ssh-agent You can shut down the ssh-agent by running the command eval `ssh-agent –k` . This command uses the SSH_AGENT_PID variable to send a signal to the ssh-agent process to shut it down. The command also unsets the environment variables that were set when you started the ssh-agent .

What is IdentitiesOnly in SSH?

The default is the name given on the command line. Numeric IP addresses are also permitted (both on the command line and in HostName specifications). IdentitiesOnly. Specifies that ssh(1) should only use the authentication identity files configured in the ssh_config files, even if ssh-agent(1) offers more identities.


1 Answers

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.

like image 157
damienfrancois Avatar answered Sep 18 '22 01:09

damienfrancois