So I'm trying to figure out a way to execute commands and read data from a pretty standard SSH-connection, using C#. The only challenge is that I can't connect to the server in question directly, I have to go through another SSH-connection, like a sort of proxy, if you will.
So far, I've been trying various APIs for this. SharpSSH and such. Here's the situation:
Me -> SSH server -> SSH target server
I need to be able to execute and read stuff in real time, as the commands I put in will wary depending on the results I get.
So far, the closest I've gotten is were I establish the connections all the way, but I do not get any info from the target server before the login timeout ends. Basically, I connect and log in to the "proxy" server, I execute "ssh targetserver", and then the whole thing goes quiet for about 30 seconds. At that point, I receive a lot of data at once. The login-promt from the target server, and a message saying I took too long to log in. The target server then closed to connection, which somehow causes the "proxy" server to flush the result so I can see what's going on.
I've tried to just execute the commands in the correct order blindly, but it seems like the APIs are unwilling to continue the line of commands once I connect to the target server. It just won't take any action until the timeout is reached.
Just to clarify; I cannot modify the servers in any way. This is the setup. I do however know that it can be done, because doing it manually through Putty is no problem at all. I am trying to recreate what Putty does here, in my C# application. In Putty, I just type "ssh server", input my credentials, and do another "ssh server". The reason I want to do this, is simply because there is a lot of routine work to be done. Same stuff over and over, and it does take quite a lot of time when it's added up.
I'm not sure wether this is a problem with the APIs, or if there is some flag or whatever I can put into my commands to make this work. I've read about flags such as the L, but it doesn't seem to work all that well for me. Both servers authenticate users by making us type in our username and password into Putty (or whatever
Anyone know how to do this? (Preferably using C# and SharpSSH.)
I also tried this in Java, and I got the exact same problem there.