Giter Site home page Giter Site logo

scala-ssh-shell's Introduction

scala-ssh-shell

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.

Usage

Embed this in your code by running the following:

val sshd = new ScalaSshShell(port=4444, name="test", user="user",
                             passwd="fluke",
                             keysResourcePath=Some("/test.ssh.keys"))
sshd.bind("pi", 3.1415926)
sshd.bind("nums", Vector(1,2,3,4,5))
sshd.start()

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:

sshd.stop()

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!

scala-ssh-shell's People

Contributors

srp avatar atry avatar jdanbrown avatar maxaf avatar aolshevskiy avatar jrudolph avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.