InfoConnect API Guide
Walkthrough / Set up Secure Connections / Set up SSH Connection
In This Topic
    Set up SSH Connection
    In This Topic

    This sample shows how to create an InfoConnect Open Systems session that connects through the Secure Shell (SSH) protocol.

    To create an SSH connection 

    1. In Visual Studio, create a new Console Application project and add references for the following InfoConnect assemblies. (Depending on your version of Visual Studio, these can be found either on the .NET tab or under Assemblies | Extensions.)
      Attachmate.Reflection
      Attachmate.Reflection.Framework
      Attachmate.Reflection.Emulation.OpenSystems
    2. Replace all the code in the Program.cs file with the following code.           
      Set up SSH Connection
      Copy Code
      using System;
      using System.Collections.Generic;
      using System.Text;
      using Attachmate.Reflection.Framework;
      using Attachmate.Reflection.Emulation.OpenSystems;
      using Attachmate.Reflection.UserInterface;
      namespace CreateSSHSession
      {
          class Program
          {
              static void Main(string[] args)
              {
                  //Start a visible instance of InfoConnect or get the instance running at the given channel name
                  Application app = MyReflection.CreateApplication("myWorkspace", true);
      
                  //Create a terminal for an Open Systems session
                  ITerminal terminal = (ITerminal)app.CreateControl(new Guid("{BE835A80-CAB2-40d2-AFC0-6848E486BF58}"));
      
                  //Disable autoconnect and then disconnect so the default settings can be changed
                  terminal.AutoConnect = false;
                  terminal.Disconnect();
      
                  //Set the terminal to use secure shell
                  IConnectionSettingsSecureShell conn = (IConnectionSettingsSecureShell)terminal.ConnectionSettings;
                  terminal.ConnectionType = ConnectionTypeOption.SecureShell;
      
                  //Specify the host name or IP address, port, and user name.
                  conn.HostAddress = "yourHostAddress";
                  conn.SSHPort = 22;
                  conn.UserName = "yourUserName";
      
                  //Make the session visible                 
                  IFrame frame = (IFrame)app.GetObject("Frame");
                  frame.CreateView(terminal);
      
                  //Connect with the new SSH settings
                  terminal.Connect();
              }
          }
      }
      
                              
      
    3.  Change the hostName and UserName variables for your system.

    To test this project

    1. In Visual Studio, press F5 to run this project.
    2. Verify that the session is an SSH session.