开发者

Error while running ssh command in java

I'm trying to run ssh command in Eclipse this way

ExpectJ exp = new ExpectJ();    
Spawn s = exp.spawn("ssh root@192.168.1.2");
. . . 
开发者_如何学运维. . . 
. . . 

But i get this as the error-

Pseudo-terminal will not be allocated because stdin is not a terminal.

If i try doing it the following way,

Spawn s = exp.spawn("ssh -t -t root@192.168.1.2");

and execute,i get this error

tcgetattr: Invalid argument

also,the code executes only half and i get this message-

Killed by signal 15.

and finally i face a timeout exception

Any Suggestions? I'm not sure what those error messages mean.


I'm not sure why you're getting the errors you're seeing, but I can say when I've needed to do ssh/scp etc. I've used this library: http://www.jcraft.com/jsch/ and it's worked very well for me.


I can use the in-built method!! Never realized that even existed.

s = exp.spawn(hostName, sshPort, userName, userPassword);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜