Hi,
I have set up my remote server for password-less login via ssh. If I run the command on my server - ssh user@remoteserver "ls -l"
I get an output, but when I try to do this via java
String[] sCmd = new String[]{"/usr/bin/ssh", " user@remoteserver", "\"ls -l\""};
Process p = Runtime.getRuntime().exec(sCmd);
int c;
InputStream in = p.getInputStream();
while ((c = in.read()) != -1) {
System.out.print((char) c);
}
it will prompt me for the user password.
Any insight is highly appreciated.
OS- AIX
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pap64dev-20071008 (SR6))
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 AIX ppc64-64 j9vmap6423-20071007 (JIT enabled)
J9VM - 20071004_14218_BHdSMr
JIT - 20070820_1846ifx1_r8
GC - 200708_10)
JCL - 20071008
$ ssh -V
OpenSSH_5.2p1, OpenSSL 0.9.8k 25 Mar 2009