0 votes
by (360 points)
edited

Is it possible to do SSH connection without calling first to Login method? I'm using VirtualTerminal object and when I call Bind on it I'm getting an exception. I can use the Telnet object instead but I prefer to use SSH

5 Answers

0 votes
by (144k points)
edited

No, this is not possible. The reason for this:

  • In the SSH protocol, the client has to authenticate to the server before it can start a shell session or execute remote commands.
  • VirtualTerminal.Bind method needs to actually start a shell session (or remote command) when binding to an Ssh object. Without this, there would be no shell session for VirtualTerminal to use.

Why do you need not to call the Login method, by the way? Would you like to use SSH without authentication, or is there another reason for this?

0 votes
by (360 points)
edited

Hi Lukas,

Maybe I'm doing something wrong. I'm building a web page. In some cases I have the user credentials in advance. In these cases I can use the SSH object with no problems. In other cases I don't have them, so I need to show the user the option to enter user/pass

but in both case I want the connection to be SSH

Another thing. I don't understand why there is a connection between the protocol type and the credentials. If we take Putty for example, you can connect with SSH to a server and then write manually user/pass. why there is a difference here?

0 votes
by (144k points)
edited

In PuTTY, when you write the username/password manually into the terminal, the terminal is not actually bound to an actual shell (or remote command) session yet (when SSH is in use). PuTTY is just using the terminal window to let you enter the credentials which are then sent to the server.

I agree that this is convenient (looks just like telnet and saves one from implementing a login dialog), and it can actually be done with TerminalControl with a bit of extra work because TerminalControl can be used in an unbound state, as described here.

To reproduce a PuTTY-like behavior, one could do this:

  1. Create an instance of Ssh object and connect to the SSH server.
  2. Create an instance of TerminalControl and use it to ask for a username/password. This is not exactly simple, but it is possible (keypresses must be handled by custom code, etc.).
  3. Use the username/password to authenticate to the SSH server.
  4. Bind the existing instance of TerminalControl to the authenticated Ssh object.

The same could be done with VirtualTerminal, but since VirtualTerminal is not visible, it is almost always used programatically and calling Ssh.Login is usually more convenient than PuTTY-style authentication. However, if you are actually using VirtualTerminal in a TerminalControl-like way (how do you display its content to the user, by the way?), you can still make it PuTTY-like using the approach outlined above.

0 votes
by (360 points)
edited

I'm actually using code that you wrote on a different thread: http://forum.rebex.net/questions/4664/create-shell-from-asp-net

I'm not sure how to use the TerminalControl here. can you modify the code to support it? or tell me how I connect the TerminalControl to the UI without doing bind first the change should be inside the if (useSsh) of the Connect

+1 vote
by (144k points)
edited

Sorry for the confusion - I was not suggesting to use TerminalControl (doing so would not be practical at all for a web application), I was just trying to explain how to achieve a PuTTY-like behavior with Rebex Terminal Emulation (and PuTTY is a Windows application).

Also, I have not realized you were actually using the proof-of-concept WebTerminal sample application.

In case of WebTerminal sample app, I see two possible ways of achieving your goal:

A) Modify TerminalEndPoint so that useName/password in the Connect method are optional. If they are not specified, instead of Bind(_session), do Bind(new LoginChannelFactory(_session)), where LoginChannelFactory would be a custom implementaion of IShellChannelFactory that simulates a telnet-like "server" (a custom instance of ShellChannel) that asks for username and password and tries authenticating to the supplied _session object. Once the authentication was successful, the custom instance of ShellChannel would pass all calls to Ssh object's `ShellChannel'.

B) Modify TerminalEndPoint so that there are separate Connect and Login method. When SSH is in selected with no username/password, just call Connect and implement the username/password code in client-side JavaScript. Once the code has the username/password, call Login method, which would do the actual Bind.

The first approach is more complicated, but it would actually work with both VirtualTerminal and TerminalControl, making it possible to implement PuTTY-like authentication both in WebTerminal sample and Windows applications. We will try giving this a try when we are back at the office in 2015!

...