4

I am currently building an application in order to learn Java. I am trying to connect to my server via SSH, execute some stuff and retrieve what the system gives me. I am using jcabi-ssh for my SSH management.

Currently I am able to SSH into the server and execute standard commands.

I am executing commands like that:

new Shell.Plain(sshpw).exec(cmd);

Where "sshpw" is a SSHByPassword object.

Now I read that I am able to execute commands through a method of the object itself instead of using shell. Since the documentations states that only the first parameter is for the command and the other three for the logging I tried the following:

sshpw.exec(cmd, System.in, System.out, System.err);

But there is absolutely no difference in output (none).

Any advice on what I do need to read up on? Dealing with external libraries is new for me so sorry if I am overlooking some major documentation.

Jason C
  • 38,729
  • 14
  • 126
  • 182
Inialk
  • 73
  • 1
  • 3
  • Does your call to `sshpw.exec` return an exit code? What is it? Also, `SSHByPassword#exec` closes the streams it gets passed as parameters, I don't know what happens if you try to close the System streams. – 11684 Oct 30 '16 at 23:19
  • My guess is that you have to add the certificate of your site to the key store (cacerts) of the executing JRE otherwise Java refuses the connection. – maraca Oct 30 '16 at 23:47
  • @maraca: SSH rarely uses any kind of certs and never uses the kind (X.509) that are in cacerts. You may be confusing SSH with SSL, which is an entirely different protocol, although both do involve the concept of 'secure'. – dave_thompson_085 Oct 31 '16 at 00:54
  • @dave_thompson_085 right, thanks, thought there's something odd but couldn't pinpoint it. – maraca Oct 31 '16 at 08:35
  • What is the `cmd`? – yegor256 Nov 19 '16 at 08:27

0 Answers0