Installing OpenSSH on Windows 7June 7, 2011 | 29 Comments Today, I was tempted to take control of a Windows machine remotely in console mode as I’m trying to script the launch and use of VLC. A quick Google search reveleaed the existence of the sshwindows project which is a more lightweight solution than a full cygwin installation. Here are the installation steps :Download and run the sshwindows installer. As the setup will tell you, some simple commands will be needed to complete the installation. Launch the windows command line tool (windows key -> type cmd -> press enter) and head to the directory in which you installed open ssh.
The steps needed to complete the installation are detailed in the docs folder in two files : quickstart.txt will quickly sum up the steps while the readme.txt is a more detailed setup and troubleshooting guide. Below is a step by step process on what I had to do to get the server running :
According to the quickstart guide, everything should work at this point but that was not the case for me. Below is the message I saw :
I solved that problem by using chown and chmod available in the bin folder to change the persmission on these files. As I found out trying to run chown, I needed a cygintl-2.dll file which I didn’t have on that computer. I ended up copying it from another computer running an up to date install of cygwin. In this up to date version, cygintl-2 was called cygintl-8, I renamed it. If you need to, download cygintl-2.dll and cygwin1.dll and place them in your OpenSSH\bin directory. Note that you will need to replace the existing cygwin1.dll.
That’s it, at this point, the server starts. You can kill it (CTRL+C) and start it as a Windows service by running
Time to test our SSH server with a client. On a different computer, run a SSH client (if the other computer is running Windows, you can use putty).
At this point, it worked for me ! Now I can connect to a Windows 7 using SSH and that makes Windows a lot cooler ! Thanks to the developer, Michael Johnson. Going further, the public key authenticationSince my goal, with all this, was to script the use of VLC from a Unix machine on the Windows one, I could use the public key authentication to bypass the interactive authentication. The SSH public key authentication system is based on the private and public keys which are expected in the user’s home folder (in a folder called .ssh). So the first step will be to define the user’s home folder on windows. Since I’m not using cygwin but open ssh for windows, it’s only the declaration of the home folder in openssh that I care for. I edited the file in c:\Program Files (x86)\OpenSSH\etc\passwd and changed the value before last (each value is separated by a . I changed the home folder for my user to /cygdrive/c/Users/<username>. Now I can go in my c:\Users\<username> folder and create a folder called .ssh. I recommend creating this folder using the command window as I don’t think it is possible with the graphical interface.
At this point, you need a public key which you should generate with the command
Now, the idea is to place my user’s public key in this folder in a file called authorized_keys. Since I’ve already setup my public key, I simply add to place it in that folder and do :
Edit your ssh server configuration file and make sure the Public Key authorization is not commented (it was okay for me by default) From your client computer, connect again using ssh <username>@<windows_ip> and you shouldn’t be prompted for a password anymore. Now, I can simply launch commands on the windows machine by doing
Finally, moving on with my project which I’ll describe in this blog upon completion. ’till then, hope this tip helps |
|