OpenSSH server on Windows using Cygwin

Sometime I need to automate some task on windows, and it’s a pain.

A solution I found is to set up an ssh server on windows and execute remotely most of the tasks.

First you have to install Cygwin and select the openssh package.

Then open an Administrator Cygwin console and type:

ssh-host-config -y -c "tty ntsec"

This will accept all the defaults and add the support for the NT system user accounts (untested).

Then you will have to add an exception for the sshd service in the windows firewall, it is located in:


If needed you can add your public ssh key in the .ssh/authorized_keys in your cygwin home.

If you trust the machine, you can activate the agent forwarding, but to make that work you have to start an ssh-agent in your .profile or .bashrc:

if [ -z "$SSH_AUTH_SOCK" -a -x ssh-agent ]; then
	eval $(ssh-agent -s)
	trap "kill $SSH_AGENT_PID" 0

Now you can start the server from your Administrator Cygwin console:

net start sshd