So first thing is download the version of libssh you need from https://www.libssh.org/files/ . In my case I am using version 0.8.5.
You will also need to install Openssl. I used a precompiled binary from here: https://indy.fulgan.com/SSL/ . Installation is straightforward. Also, zlib is optional while compiling libssh. I did not include it as I didn't need it. Cmake is also required if you do not have it installed already.
Extract the tarball into whatever directory you want it in. In my case I extracted it into C:/libs/libssh-0.8.5 . Create an empty directory to generate the build files into. For the sake of simplicity I just chose C:/libs/libssh-0.8.5/output .
When you open Cmake, set the source code location to C:/<path>/libssh-0.8.5/ and the output location to wherever you created your output directory.
Now click "Configure". You will be asked to choose the version of Visual Studio you are using.
Click finish. Cmake will do it's thing for a bit. If you did NOT install zlib like I did, you will get this error. I think this is where most people are getting stuck. In the forums I saw, people were complaining about this.
Just scroll through the entries in the list and uncheck "WITH_ZLIB". The only reason I compiled this without zlib was that I was just working on a small personal project and didn't see a reason to include it.
When Cmake is done, the contents of your output directory should be full of the appropriate directories, files, VC++ Projects and "libssh.sln". Open the solution in Visual Studio. It should include these projects:
Build it via Build->Build Solution or (Crtl+Shift+B). The resulting .dll, .exp and .lib files will be located in your output directory in C:/<output path>/src/release .
In hindsight this was incredibly simple, so I'm not sure why I had trouble with it. I think the people in the forums/emails I saw were trying to generate the build files in the wrong directory with Cmake. I was having problems getting it to build in VS, but that was probably my lack of experience with it. Anyways, hope this helped someone!