Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have installed openSSH as part of the latest cygwin distribution. My goal is to use the ssh-agent from native window console (cmd) in order to login passwordless in a various number of Linux machines.

I have generated the keys and uploaded them to the appropriate directories in the remote hosts and everything works fine.

The only issue I have is that everytime I open a new cmd I have to run 'ssh-add', enter the passphrase and then I am able login passwordless in the remote hosts. Is there a way to overcome this problem? The ideal solution would be to run ssh-add only once.

fyi: I'm opening the cmd as an argument to the ssh-agent: 'ssh-agent cmd'

share|improve this question
a small update: cygwin does not provide keychain as an .exe, thus I cannot use it in order to store my passwords. So I had to use just an empty passphrase in order to avoid typing the passphrase everytime or making an ssh-add everytime I started a new cmd. – nonouco Oct 2 '12 at 9:14

You will not be able to run ssh from the native command window. You will need to run the Cygwin bash "window" in order to run any of the Cygwin binaries.

Having said that, in the Cygwin bash "windows", you need to save the output of ssh-agent to a file and then source that file into any of the login scripts where you want to use the cached credentials. In the first "window", run:

$ ssh-agent >your_save_file     # Starts ssh-agent, saves shell variables
$ . your_save_file              # Loads saved shell variables into current shell
$ ssh-add                       # Adds keys into ssh-agent

In each of the others, run:

$ . your_save_file

All of the "windows" and child processes started after the . your_save_file command is run will be able to use the credentials cached in ssh-agent. Any time that the ssh-agent is stopped or killed, or after a system reboot, you will need to run the first set of commands again. If you are in doubt about whether or not the cached credentials are available in a particular shell, run

$ ssh-add -l            # Show list of loaded keys in ssh-agent
share|improve this answer
thanks for your answer. However I am able to run ssh and other cygwin .exe files. Actually, I can connect to remote hosts using cygwin's ssh from windows native cmd. – nonouco Oct 1 '12 at 15:31
@Yedric: You can do the first step in a single command, with no temporary file: eval $(ssh-agent) – MikeK Sep 17 '14 at 15:48
ssh does work in cmd.exe, the question is if ssh-agent can also work somehow. – amenthes Oct 2 '14 at 9:53
This is wrong. I have been using cygwin's ssh tools from both cmd and powershell with no issues. – Asad Saeeduddin Nov 15 '14 at 21:22
@MikeK: Yes, you can, however, that does not allow other processes to use the ssh-agent. By saving to a file, you can source that file in other shells to provide access to the same ssh-agent . – Yedric Dec 17 '14 at 17:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.