sshnet / sshnet/SSH.NET

How SshCommand keep its Session State LIKE teminal

Open
#827 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
4.4k
Forks
993
Avg merge
9d 21h
Merged PRs (30d)
1

Description

void Main()
{
	var host = "127.0.0.1";
	var port = 5022;
	var username = "root";
	var password = "toor";

	using var ssh = new SshClient(host, port, username, password);
	if (!ssh.IsConnected)
	{
		ssh.Connect();
	}
	Console.WriteLine(ssh.RunCommand("pwd").Result.Trim());
	Console.WriteLine(ssh.RunCommand("cd /etc && pwd").Result.Trim());
	Console.WriteLine(ssh.RunCommand("pwd").Result.Trim());

	// using var cmd = ssh.CreateCommand("pwd");
	// var res = cmd.Execute();
	// Console.Write(res);
	// cmd.CommandText = "cd /etc && pwd"; // error CommandText is readonly
}

result:

/root
/etc
/root

expect:
/root
/etc
/etc

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the supplied C# reproduction and start by tracing SshClient.RunCommand and the command/session behavior it exercises. Done should be demonstrated when the three commands produce /root, /etc, and /etc, with the behavior covered by an appropriate regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.