JASSH is a high level scala SSH API for easy and fast operations on remote servers. It is JSCH based.

Latest changes for 0.9.3

  • now using sbt-assembly 0.8.3
  • fixes relatives to implicit conversions with SSHPassword
  • fixes relatives to implicit conversion to SSHCommand and SSHBatch
  • For SSHBatch : execute, executeAndTrim, executeAndTrimSplit
    renamed to : executeAll, executeAllAndTrim, executeAllAndTrimSplit
  • Using Iterable instead of List
  • external (package) usage tests completed (ExternalSSHAPITest.scala)
  • small fix about how private key passphrase is taken into account (when pub-key auth is used)

Latest changes for 0.9.2

  • date '+%Y-%m-%d %H:%M:%S %z' %z and %Z gives the same result on AIX, this result corresponds to linux %Z. So modifying code to use %Z instead of %z. Now using GMT, "date -u '+%Y-%m-%d %H:%M:%S %Z'" in order to everything work well in all cases.
  • SSH.once(Option[SSHOptions]) fix linked to Option type result not at the right place
  • New test source file : ExternalSSHAPITest.scala => Testing the API from an external package
  • Fixed : minor problem with script when invoking jajmx.SSH... or fr.janalyse.sh.SSH... without imports...

Latest changes for 0.9.1

  • SSH tunneling fix, cleanup, and scaladocumented
  • Intricated SSH tunneling test added (self intrication, to simplify test case)

Latest changes for 0.9.0:

  • now using sbt-assembly 0.8.1
  • now using scalatest 0.8
  • new helper methods (For the list of already available helper methods):
    • test
    • exists
    • isFile
    • isDirectory
    • isExecutable
  • findAfterDate & date helper fix !!
    Shell.date -> remote system time zone is now taken into account
  • Test cases fixes :
    Forcing parallelism to 6 ! for test case "Simultaenous SSH operations"
  • Code factorization :
    • ShellOperations trait added. Inherited by SSH and SSHShell.
    • TransferOperations trait added. Inherited by SSH and SSHFtp.
  • SCP supported, for no-persistent transferts sessions, SCP is now used by default (instead of SFTP)
    (e.g. : SSH class transfert operation is now using SCP by default).
  • noneCipher switch added to SSHOptions for higher performance SCP transfert (true by default)
    (http://www.psc.edu/index.php/hpn-ssh)
  • transfert (receive) tests added
    Reference time on a local system: 500Mb using 5 SCP command (100Mb/cmd) takes on the same system 8.7s (~62Mo/s by file)
    file transfert performances (with content loaded in memory)
    • Bytes rate : 38,6Mb/s 500Mb in 12,9s for 5 files - byterates using SCP
    • Bytes rate : 44,9Mb/s 500Mb in 11,1s for 5 files - byterates using SCP (with none cipher)
    • Bytes rate : 38,5Mb/s 500Mb in 13,0s for 5 files - byterates using SFTP
    • Bytes rate : 46,0Mb/s 500Mb in 10,9s for 5 files - byterates using SFTP (with none cipher)
    • Bytes rate : 39,5Mb/s 500Mb in 12,7s for 5 files - byterates using SFTP (session reused
    • Bytes rate : 46,7Mb/s 500Mb in 10,7s for 5 files - byterates using SFTP (session reused, with none cipher)
    • Bytes rate : 29,5Mb/s 500Mb in 16,9s for 500 files - byterates using SCP
    • Bytes rate : 32,1Mb/s 500Mb in 15,6s for 500 files - byterates using SCP (with none cipher)
    • Bytes rate : 26,7Mb/s 500Mb in 18,7s for 500 files - byterates using SFTP
    • Bytes rate : 29,5Mb/s 500Mb in 16,9s for 500 files - byterates using SFTP (with none cipher)
    • Bytes rate : 37,7Mb/s 500Mb in 13,3s for 500 files - byterates using SFTP (session reused)
    • Bytes rate : 43,7Mb/s 500Mb in 11,4s for 500 files - byterates using SFTP (session reused, with none cipher)
  • Code cleanup & Scaladocumenting
  • SSH compression now supported
  • For easier SSH Tunneling, new methods are now available :
    • def remote2Local(rport:Int, lhost:String, lport:Int)
    • def local2Remote(lport:Int, rhost:String, rport:Int)
  • SSHCommand, SSHBatch methods ! renamed to §§

CAVEATS :

  • ssh persisted shell session operations must be executed within the same thread, do not span a persisted shell session across several threads => it may generate exception
    So be careful when using REPL with default config, as each "evaluation" is done within a new thread !
    Workaround : Start the interpreter (REPL) with the "-Yrepl-sync" option.
    No problem with SBT as a scala console started from SBT will execute all its entries in the same thread !
    No problem in scala scripts.
  • SCP operations can't retrieve special file such as /proc/cpuinfo, because their size are not known !
    Workarounds : use SFTP OR use a command such as "cat /proc/cpuinfo". (The last one is the "best workaround", will work in all cases)

hello scala script


#!/bin/sh
exec java -jar jassh.jar -nocompdaemon -usejavacp -savecompiled "$0" "$@"
!#

print(jassh.SSH.shell("localhost", "test", "testtest") {_ execute "echo Hello `hostname`" } )


remote vmstat scala script

(The following script assume that the current user has already automatic access to the given remote host using SSH public key authentication.)

#!/bin/sh
exec java -jar jassh.jar -nocompdaemon -usejavacp -savecompiled "$0" "$@"
!#
val host=if (args.size>0) args(0) else "localhost"
val user=if (args.size>1) args(1) else util.Properties.userName
val freq=if (args.size>2) args(2) else ""
val numb=if (args.size>3) args(3) else ""
val vmstatcmd="vmstat %s %s".format(freq, numb)

jassh.SSH.once(host, user) {
_.run(vmstatcmd, _.foreach(println _)).waitForEnd
}

smallest script : print remote system name (uname)


#!/bin/sh
exec java -jar jassh.jar -nocompdaemon -usejavacp -savecompiled "$0" "$@"
!#

println(jassh.SSH.shell("localhost", "test", "testtest") { _.uname})