3

I am working on a Windows version of a server application that communicates with a web application. The web application originally worked with a Linux server, and would SSH into Linux to execute commands on the server. My plan is to build a C++ server using Qt to receive commands from the web application, and process them to do the windows version of what those commands are.

So for example, if the web application originally sent "echo $HOME" and received back the home directory, I want to receive that same SSH command on my Windows server, then process it so if the server was configured for the home directory to be C:\Example\, then it would send back C:\Example\. My goal is to make as little change to the web application, and instead have the Windows server process the Linux SSH commands to do the Windows equivalent.

I've never worked with libssh before, but from some searching I found it and read that it could be used as an SSH2 server. Basically my question here, is how would I use libss2 to create a server in my Qt project to allow this web application to SSH in and send commands.

If you think there is a better way then libssh please let me know, this is just what I have found through searching.

UPDATE: I found this code of a server example. https://github.com/substack/libssh/blob/master/examples/samplesshd-tty.c

Honestly, I'm very confused by it. I'll probably be able to break it down and understand what's happening after a few hours of Googling and working through the code. But If anyone would be willing to walk me through main explaining what's happening at each step, that would be appreciated.

Shafik Yaghmour
  • 154,301
  • 39
  • 440
  • 740
Mitch
  • 519
  • 2
  • 7
  • 16
  • 'and instead have the Windows server process the Linux SSH commands to do the Windows equivalent.' <- You *do* realize that you would have to code all of the 'translation', i.e. turning the Linux commands into 'equivalent' Windows ones? – us2012 Feb 06 '13 at 06:28
  • Yes I do realise that. It's not like I plan on coding every linux command into this Windows server. The commands it typically sends to linux through ssh are mostly calls to bash scripts that ran tasks on the server. I'm going to have to code the function of those bash scripts into my Windows server anyway, so really I'll just be interpreting the Linux commands to know which class/method to call for the equivalent of the bash script. That part isn't my problem, I'm just stuck trying to figure out how to get my Qt program to accept an SSH2 connection and receive the commands. – Mitch Feb 06 '13 at 08:06
  • There is no need to implement a shell or to open one. You can define your own protocol if you implement the server. – asn Feb 16 '13 at 09:33

0 Answers0