This project is read-only.

cd command can't execute correctly.

Mar 27, 2012 at 10:08 AM

I download the SSH.NET library yesterday. And I  use SshClient class to write a Demo. I found that cd command do not work well.  When i execute "cd weiming", but the directory still stay in the current path. 

Mar 27, 2012 at 1:43 PM



Can you publish code example of how you use it and where you expect the new directory to change so I could run this example here and test it?

Also, does it occur when you connect to specific server or to any server?




Apr 27, 2012 at 6:18 PM


For each command executed, a new context is set, so a command 'cd weiming' in 1 command, and a new command 'ls' would actually not list the 'weiming' directory, but the initial directory. To change the working directory, use SshClient.ChangeDirectory() or chain multiple commands in 1 execute as such: 'cd weiming; ls', and check result for remote output.

Apr 27, 2012 at 7:21 PM

small correction,

Note SshClient does not have ChangeDirectory only SftpClient does.




Jun 15, 2012 at 12:07 PM

I have the same problem cd command is not working.
I have just downloaded the lib and start to use it but when i try to change directory it will not change directory.

var client = new SshClient(root, XXXX, XXXX);
client.RunCommand("cd /etc/");
var cmd = client.RunCommand("pwd");


If I start a Putty and do the same it work.


Jun 18, 2012 at 2:08 PM



Unfortunately command execution occurs inside unique sessions, it seems, so nothing from one command execution will be remember in the next command execution,


You can chain all command together in one line if needed.


Hope it helps.