Re: Login, su to root, execute command - WeOnlyDo Discussion board

Re: Login, su to root, execute command (General questions)

by shin, Tuesday, May 27, 2008, 05:37 (5815 days ago) @ Kaliorin

Hi ,wodDamir :

I have a problem in my ASP code and I don't know what's wrong with it.
Can you please try to find the problem, thanks.

Code :
<
dim SSH
set SSH = Server.CreateObject( WeOnlyDo.wodSSHCom.1 )

hostname = 10.80.90.100
login = oam8adm
password = A12345
rootpass = scsicard

ssh.Hostname = hostname
ssh.Login = login
ssh.Password = password
ssh.Blocking = 1
//ssh.Protocol = 3
//SSH.Port = 22
ssh.Connect

// once connected, wait for prompt
ssh.WaitFor regex:[$ #>] $ ,5

// if anything left in incoming buffer, delete it
If ssh.DataReady > 0 Then
response.write ssh.Receive
end if

// execute su command, wait for password prompt
ssh.Execute su - & vbLf, Password: ,5

// send password and wait for command prompt
ssh.Send rootpass & vbLf
ssh.WaitFor regex:[$ #>] $ ,5

// if anything left in incoming buffer, delete it
If ssh.DataReady > 0 Then
ssh.Receive
end if

// execute command and dump it//s output to a messagebox
ssh.Execute ls -al & vbLf, regex:[$ #>] $ ,10

// and disconnect
ssh.Disconnect
>
Result :
WeOnlyDo.wodSSHCom.1 (0x800A274C)
The current connection has timeout.
/ssh/ssh.asp, line 60


Complete thread: