Your Scala SSH backdoor into the jvm
Scala Java
Switch branches/tags
Nothing to show
Clone or download
dbudworth Merge pull request #8 from ActionIQ/master
Support for setting idle timeout
Latest commit ec3a3ec Apr 9, 2016
Failed to load latest commit information.
project update apache dep Mar 13, 2016
src/main update apache dep Mar 13, 2016
.gitignore git ignores Aug 7, 2015
LICENSE initial code for scala 2.9.1 Oct 9, 2011 sbt artifact setting caused classpath to change Mar 31, 2012
build.sbt update apache dep Mar 13, 2016


Backdoor that gives you a scala shell over ssh on your jvm

NOTE: The shell is not sandboxed, anyone access the shell can touch anything in the jvm and do anything the jvm can do including modifying and deleting files, etc. Use at your own risk. No guarantees are made regarding this being secure.


Embed this in your code by running the following:

val sshd = new ScalaSshShell(port=4444, name="test", user="user",
sshd.bind("pi", 3.1415926)
sshd.bind("nums", Vector(1,2,3,4,5))

Most of that should be self explanatory. The 'name' is the name that will be used for the parent thread, as well as the name that will appear in the prompt that the user sees. A good idea is to name it after the service the jvm is providing so if the user sshes into the wrong jvm they'll immediately see a visual indication that they aren't where they expected to be.

To shut down ssh service, call:


To generate your keys run ScalaSshShell.generateKeys(), which can be done from a scala shell:

scala> peak6.util.ScalaSshShell.generateKeys("src/main/resources/test.ssh.keys")

Note that the shell does not work when running under sbt's console.

To run the included example, run the following with sbt 0.7:

$ sbt update
$ sbt compile
$ sbt package
$ scala -cp "$(find lib_managed | grep jar$ | xargs echo | sed -e 's# #:#g'):./target/scala-2.9.1/scala-ssh-shell_2.9.1-0.0.1-SNAPSHOT.jar" peak6.util.ScalaSshShell

Now you can ssh in from a separate window, using "fluke" for the password:

$ ssh -l user -p 4444 localhost
user@localhost's password:
Connected to test, starting repl...
Welcome to Scala version 2.9.1.r0-b20110831114755 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0).
Type in expressions to have them evaluated.
Type :help for more information.
test> nums.sum
res0: Int = 15
test> pi/2
res1: Double = 1.5707963
test> println("Hello World!")
Hello World!