我正在尝试为用户设置密码,我在我的程序中添加SSH。
到目前为止,这是我的代码:
private void button1_Click(object sender, EventArgs e)
{
SshStream ssh = new SshStream("IP", "root", "Password");
ssh.Prompt = "#";
ssh.RemoveTerminalEmulationCharacters = true;
ssh.Write("adduser " + textBox1.Text);
textBox3.Text = ssh.ReadResponse();
ssh.Close();
}
我如何在按钮上发送这些命令:
passwd textbox1.text
然后服务器返回以下内容:
New UNIX password:
Retype new UNIX password:
我需要用TextBox2.Text
的值填充每条线我正在使用此库:http://www.tamirgal.com/blog/page/sharpssh.aspx
尝试以下:
ssh.Write("thepasswordnthepassword | passwd " + textBox1.Text);
基本上将两个密码输送到PassWD函数