Help me ssh Auto input password with Expect
thanhlapvn opened this issue · 4 comments
I found Expect.exe for my Windows, but not found Spawn.exe Send.exe
I want auto enter password with batch, script:
setLocal EnableDelayedExpansion
@expect.exe "%~f0"
@EXIT /b
-- Lines starting with '@' are replaced to '--@' by expect.exe
-- to embed the script into the batchfile.
echo(true)
if spawn([[ssh.exe]],"root@localhost -p 2222") then
expect("password:")
echo(false)
send("alpine\r")
expect("~]$")
echo(true)
send("exit\r")
end
Yeah! i can run but error:
C:\Users\Thanh Lap Apple\Desktop\all jailbreak bypass win>"C:\Users\Thanh Lap Apple\Desktop\all jailbreak bypass win\Win\expect.exe" "C:\Users\Thanh Lap Apple\Desktop\all jailbreak bypass win\Win\test.lua"
echo(true)
if spawn([[C:\Users\Thanh Lap Apple\Desktop\all jailbreak bypass win\win\file\ssh.exe]],"root@localhost -p 2222") then
expect("password:")
echo(false)
send("alpine\r")
expect("~]$")
echo(true)
send("exit\r")
end
OUTPUT:
"C:\Users\Thanh Lap Apple\Desktop\all jailbreak bypass win\win\file\ssh.exe" "root@localhost -p 2222"
ssh: Could not resolve hostname localhost -p 2222: No such host is known.
Try "root@127.0.0.1 -p 2222"
Or separate the args "root@127.0.0.1" "-p 2222"
How about spawn("ssh.exe","-p","2222","root@127.0.0.1")
?