What looked at first like a simple task – turned out to cost me hours of trial and error.
Some of the problems I’ve encountered:
- Cygwin’s SSHd, OpenSSH and CopSSH all work great on Windows EC2 instances. Until you try to bundle an instance. After you launch a bundled instance – the SSHd service wouldn’t run, because of permissions problems – and throws weird error messages in the different logs.
- It turned out that Sysprep was responsible for this – mangling the permissions of the SSHd users.
- Turning Sysprep off as suggested in some places sounds like a recipe for problems down the road.
- Couldn’t find the source code of an SSHd implemented in Java, and FreeSSHd. Wouldn’t be smart to use closed-source applications for this, security wise…
- Couldn’t find any other SSHd client, or a full solution for this specific problem.
I Googled everywhere, until I assembled the solution which consists of:
- Installing Cygwin’s SSHd (thank you LifeHacker).
- AutoExNT service is used to run a batch file right after the machine’s launch (Thank you Microsoft).
- Update_Cygwin solved the permissions problem (Thank you VCL).
So, the steps to SSH into a Windows machine on Amazon EC2 are these:
- Install Cygwin, make sure you include the OpenSSH package.
- chmod +r /etc/passwd
- chmod +r /etc/group
- chmod 755 /var
- Choose root as the name of the privileged account.
- Copy your public key into the authorized_keys file of the account you’d like to log-in with.
- Install the AutoExNT service.
- Run the update_cygwin script right after each instance launch.
- Don’t forget to open the SSH port on the security group of the instance.
I still don’t understand:
- How come Windows doesn’t come pre-configured with an SSHd service. What do people use in order to administer Windows Server machines? Unsecure Telnet? Do they all use Remote Desktop for this?? Very weird…
- How come there’s no solution for this already on Amazon EC2 forums? Saw lots of people run into this problem, and it seems like pretty basic stuff. I guess that Windows Server administration still isn’t that popular…
Thanks for everybody on the forum that saved me valuable time getting this problem behind me…
Now for the real work 🙂