JAnalyseSSH is a jsch based scala SSH API which aims to simplify SSH operations.

The hello world script...

(It requires a local user named "test" with password "testtest", remember that you can remove the password, if your public key has been added in authorized_keys file of the test user)

#!/bin/sh
exec java -jar jassh.jar -usejavacp "$0" "$@"
!#
import fr.janalyse.ssh._
SSH.shell(host="localhost", username="test", password=Some("testtest")) { sh =>
println(sh.execute("""echo -n "Hello World from `hostname`" """))
}

... and the remote vmstat script


#!/bin/sh
exec java -jar jassh.jar -usejavacp "$0" "$@"
!#
import fr.janalyse.ssh._
SSH.once(host="localhost", username="test", password=Some("testtest")) { ssh =>
val executor = ssh.run("vmstat 1 10", (l)=> l foreach {println(_)})
executor.waitForEnd
}


Releases notes for 0.7.0

  • Added new method to SSH : newShell & newSftp for user to manage themselves shell and sftp session
  • Some internal changes to SSHExec class, in order to try to remove actor dependency. Mixing actors systems looks problematic
  • SSHShell new implementation, no more actors used, better performances and behavior, ... (throughput : 504 cmd/s using persistency)
  • SSHExec last result line is no longer lost
  • SSHOptions : new parameter : "prompt" to enable custom shell or console command to be use.
    prompt provide to SSHShell the way to separate command results
  • SSHOptions : connectionTimeout renamed into timeout
  • Various cleanup and enhancements
  • Tests : compare performances persistent SSHShell versus SSHExec commands throughputs
  • SSH : Add an execute immediate method which rely on SSHExec, not SSHShell ! (throughput : 93cmd/s)
    execOnce & execOnceAndTrim
  • SSHExec : Do not rely on DaemonActor/Actor anymore
  • SSHShell : Removed init Thread.sleep => Better performances (throughput : 37 cmd/s instead 1cmd/s)
  • SSH.connect becomes SSH.once
  • Removing apply in SSH class as it may encourage bad usage, and close not called