Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7593405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:09:39+00:00 2026-05-30T21:09:39+00:00

I’m trying to connect to Linux using SharpSSH, but am unable to. I want

  • 0

I’m trying to connect to Linux using SharpSSH, but am unable to. I want to run some Linux commands from my .NET application.

Install Instructions:

SharpSsh – .NET library to connect to UNIX via SSH
– create account @ codeproject.com
– http://www.codeproject.com/Articles/11966/sharpSsh-A-Secure-Shell-SSH-library-for-NET (download demo project and binaries/dll files)
– copied into “SharpSsh” folder

I’m running the sharpSshTest console application that comes with this download. When I manually SSH (port 22) to Linux via Putty for same host/login/password, I’m able to connect fine. When connecting with the same host and credentials via .NET, I get an exception thrown in the Tamir.sharpSsh .NET library.

Unix distribution and version:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 5.0.9 (lenny)
Release:        5.0.9
Codename:       lenny

StackTrace:

   at Tamir.SharpSsh.jsch.Session.connect(Int32 connectTimeout)
   at Tamir.SharpSsh.jsch.Session.connect()
   at Tamir.SharpSsh.SshStream..ctor(String host, String username, String password)
   at sharpSshTest.sharpSshTest.SshStream() in C:\Source\{path}\selenium_references\sharpSsh_Demo\sharpSsh.demo\sharpSshTest.cs:line 76

Line 76 in sharpSshTest.cs:

SshStream ssh = new SshStream(host, user, pass);

Value of e.Message:

{"verify: False"}

Here’s the code if it helps:

using System;
using Tamir.SharpSsh;
using System.Threading;

namespace sharpSshTest
{
    /// <summary>
    /// Summary description for sharpSshTest.
    /// </summary>
    public class sharpSshTest
    {
        static string host, user, pass;
        public static void Main()
        {
            PrintVersion();
            Console.WriteLine();
            Console.WriteLine("1) Simple SSH session example using SshStream");
            Console.WriteLine("2) SCP example from local to remote");
            Console.WriteLine("3) SCP example from remote to local");
            Console.WriteLine();

            INPUT:
            int i=-1;
            Console.Write("Please enter your choice: ");
            try
            {
                i = int.Parse( Console.ReadLine() );
                Console.WriteLine();                
            }
            catch
            {
                i=-1;
            }

            switch(i)
            {
                case 1:
                    SshStream();
                    break;
                case 2:
                    Scp("to");
                    break;
                case 3:
                    Scp("from");
                    break;
                default:
                    Console.Write("Bad input, ");
                    goto INPUT;
            }
        }

        /// <summary>
        /// Get input from the user
        /// </summary>
        public static void GetInput()
        {
            Console.Write("Remote Host: ");
            host = Console.ReadLine();
            Console.Write("User: ");
            user = Console.ReadLine();
            Console.Write("Password: ");
            pass = Console.ReadLine();
            Console.WriteLine();
        }

        /// <summary>
        /// Demonstrates the SshStream class
        /// </summary>
        public static void SshStream()
        {
            GetInput();

            try
            {           
                Console.Write("-Connecting...");
                SshStream ssh = new SshStream(host, user, pass);
                Console.WriteLine("OK ({0}/{1})",ssh.Cipher,ssh.Mac);
                Console.WriteLine("Server version={0}, Client version={1}", ssh.ServerVersion, ssh.ClientVersion);
                Console.WriteLine("-Use the 'exit' command to disconnect.");
                Console.WriteLine();

                //Sets the end of response character
                ssh.Prompt = "#";
                //Remove terminal emulation characters
                ssh.RemoveTerminalEmulationCharacters = true;

                //Reads the initial response from the SSH stream
                Console.Write( ssh.ReadResponse() );

                //Send commands from the user
                while(true)
                {
                    string command = Console.ReadLine();
                    if (command.ToLower().Equals("exit"))
                        break;

                    //Write command to the SSH stream
                    ssh.Write( command );
                    //Read response from the SSH stream
                    Console.Write( ssh.ReadResponse() );
                }
                ssh.Close(); //Close the connection
                Console.WriteLine("Connection closed.");
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }

        /// <summary>
        /// Demonstrates the Scp class
        /// </summary>
        /// <param name="cmd">Either "to" or "from"</param>
        public static void Scp(string cmd)
        {
            GetInput();

            string local=null, remote=null;

            if(cmd.ToLower().Equals("to"))
            {
                Console.Write("Local file: ");
                local = Console.ReadLine();
                Console.Write("Remote file: ");
                remote = Console.ReadLine();
            }
            else if(cmd.ToLower().Equals("from"))
            {
                Console.Write("Remote file: ");
                remote = Console.ReadLine();
                Console.Write("Local file: ");
                local = Console.ReadLine();
            }

            Scp scp = new Scp();
            scp.OnConnecting += new FileTansferEvent(scp_OnConnecting);
            scp.OnStart += new FileTansferEvent(scp_OnProgress);
            scp.OnEnd += new FileTansferEvent(scp_OnEnd);
            scp.OnProgress += new FileTansferEvent(scp_OnProgress);

            try
            {
                if(cmd.ToLower().Equals("to"))
                    scp.To(local, host, remote, user, pass);
                else if(cmd.ToLower().Equals("from"))
                    scp.From(host, remote, user, pass,local);
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.ReadLine();
        }

        static void PrintVersion()
        {
            try
            {               
                System.Reflection.Assembly asm
                    = System.Reflection.Assembly.GetAssembly(typeof(Tamir.SharpSsh.SshStream));
                Console.WriteLine("sharpSsh v"+asm.GetName().Version);
            }
            catch
            {
                Console.WriteLine("sharpSsh v1.0");
            }
        }

        #region SCP Event Handlers

        static ConsoleProgressBar progressBar;

        private static void scp_OnConnecting(int transferredBytes, int totalBytes, string message)
        {
            Console.WriteLine();
            progressBar = new ConsoleProgressBar();
            progressBar.Update(transferredBytes, totalBytes, message);
        }

        private static void scp_OnProgress(int transferredBytes, int totalBytes, string message)
        {
            progressBar.Update(transferredBytes, totalBytes, message);
        }

        private static void scp_OnEnd(int transferredBytes, int totalBytes, string message)
        {
            progressBar.Update(transferredBytes, totalBytes, message);
            progressBar=null;
        }

        #endregion SCP Event Handlers


    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:09:40+00:00Added an answer on May 30, 2026 at 9:09 pm

    Looks like that project is no good. Downloaded the new one here, which consists of the actual source code of the new “SharpSSH” class library project and a console application called “Examples” when you open the Visual Studio solution file.

    http://www.tamirgal.com/blog/page/SharpSSH.aspx#news

    When launching the “Examples” console application, it worked!

    SharpSSH-1.1.1.13
    
    JSch Smaples:
    =============
    1)      Shell.cs
    2)      AES.cs
    3)      UserAuthPublicKey.cs
    4)      Sftp.cs
    5)      KeyGen.cs
    6)      KnownHosts.cs
    7)      ChangePassphrase.cs
    8)      PortForwardingL.cs
    9)      PortForwardingR.cs
    10)     StreamForwarding.cs
    11)     Subsystem.cs
    12)     ViaHTTP.cs
    
    SharpSSH Smaples:
    =================
    13)     SSH Shell sample
    14)     SSH Expect Sample
    15)     SSH Exec Sample
    16)     SSH File Transfer
    17)     Exit
    
    Please enter your choice: 13
    
    Enter Remote Host: {type host here}
    Enter Username: testjobs
    Use publickey authentication? [Yes|No] :No
    Enter Password: helloworld
    
    Connecting...OK
    Linux gmqa 2.6.32-5-686-bigmem #1 SMP Thu Apr 7 22:17:10 UTC 2011 i686
    
    The programs included with the Debian GNU/Linux system are free software;
    the exact distribution terms for each program are described in the
    individual files in /usr/share/doc/*/copyright.
    
    Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
    permitted by applicable law.
    Last login: Tue Mar  6 09:58:32 2012 from {machine name}
    testjobs@gmqa:~$
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.