This project is read-only.

How to pass password while creating new User

Sep 16, 2011 at 1:58 PM

Hi,

How can i create a new user in unix and assign a password to it using SSH.Net.

Actually i am able to create new user but unable to assign the paasword.

my code looks like this.

var objClient = new SshClient("172.168.11.90", "root", "vikas123");

 

objClient.Connect();

 var cmd = objClient.RunCommand("useradd -m -g TestUser ;echo \"test123\"  | passwd testuser");

 var result = cmd.Result; 

 

Response.Write(cmd.Error);

The error which i am getting is

Changing password for user TestUser.
New UNIX password: Retype new UNIX password: New UNIX password: New UNIX password: passwd: Authentication information cannot be recovered

 

Please help.

Thanks & regards,

Vikash

Sep 19, 2011 at 1:31 PM

Hi,

Could any one help me with the above problem.

Regards,

Vikash

Sep 23, 2011 at 5:46 PM

Sorry for late response, but I was hoping that someone else have a solution for you since I am not aware of any way to do it.

Unfortunately it seems that commands that require "sudo" in front of them are note supported by SSH when using the command object.