• Stars
    star
    71
  • Rank 443,012 (Top 9 %)
  • Language
    Scala
  • License
    Apache License 2.0
  • Created over 10 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

High level scala SSH API for easy and fast operations on remote servers.

JASSH - the SCALA SSH API Build Status License Codacy codecov

High level scala SSH API for easy and fast operations on remote servers.

This API is JSCH based. Interfaces are stable. Many helper functions are provided to simplify unix operations ps, ls, cat, kill, find, ..., an other goal of this API is to create an unix abstraction layer (Linux, Aix, Solaris, Darwin, ...).

One of the main difference of this API with others is that it can work with persisted shell sessions. Many commands can then be sent to an already running and initialized shell session ! Thanks to this feature you can greatly speed up your SSH shell performances, from 70 cmd/s to more than 500 hit/s ! There is no differences in API between persisted and not persisted shell sessions, that's the reason why the API looks very simple from scala point of view; when you execute a command in a shell persisted session you get directly the output of the command but not the return code. The return code will be accessible only indirectly using for example a "echo $?" command.

The current release doesn't provide full shell interaction with executed commands, you only send a command and get the result, but I'm currently working to provide full interactivity, to allow interaction with commands such as to provide data after the command is started (send a password once the prompt is visible, ...). This work is currently visible through SSHReact class and SSHReactTest test class.

In your build.sbt, add this (available in maven central) :

libraryDependencies += "fr.janalyse"   %% "janalyse-ssh" % version

(starting from 0.10, java 8 bytecodes are used, and scala 2.10, 2.11 and 2.12 are supported)

Latest version: Maven Scaladex

Scala docs


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 "$0" "$@"
!#
jassh.SSH.once("localhost", "test", "testtest") { ssh =>
  print(sh.execute("""echo "Hello World from $(hostname)" """))
}

Persisted shell session

#!/bin/sh
exec java -jar jassh.jar "$0" "$@"
!#
jassh.SSH.shell("localhost", "test", "testtest") { sh =>
  import sh._
  println(s"initial directory is ${pwd}")
  cd("/tmp")
  println(s"now it is ${pwd}")
}

Shell session to an SSH enabled PowerShell Server (windows)

This functions much the same as a regular SSH connection, but many of the unix like commands are not supported and the terminal behaves differently

import fr.janalyse.ssh._

val settings = SSHOptions(host = host, username=user, password = pass, prompt = Some(prompt), timeout = timeout)
val session = SSH(settings)

val shell = session.newPowerShell

println(shell.ls)
println(shell.pwd)

SSH Configuration notes

To turn on/off ssh root direct access or sftp ssh subsystem.

    Subsystem       sftp    ...     (add or remove comment)
    PermitRootLogin yes or no       (of course take care of security constraints)

AIX SSHD CONFIGURATION :

    vi /system/products/openssh/conf/sshd_config
    /etc/rc.d/rc2.d/S99sshd reload

LINUX SSHD CONFIGURATION

    vi /etc/ssh/sshd_config
    /etc/init.d/sshd reload

SOLARIS SSHD CONFIGURATION

    vi /usr/local/etc/ssh/sshd_config
    svcadm restart ssh

MAC OS X CONFIGURATION

    sudo vi /etc/sshd_config
    sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist

More Repositories

1

code-examples-manager

Software tool to manage your notes, scripts, code examples, configs,... to publish them as gists or snippets
Scala
37
star
2

zio-lmdb

Lightning Memory Database (LMDB) for scala ZIO
Scala
36
star
3

jajmx

scala JMX API
Scala
31
star
4

sotohp

Photos management
Scala
27
star
5

scala-drools-dummy-project

Minimalist scala drools project
Scala
19
star
6

coursier-launcher

coursier docker container for efficient application or service download and startup
Makefile
9
star
7

zwords

A wordle game for communities
Scala
8
star
8

jaseries

scala API for time numerical series operations.
Scala
7
star
9

primes

Playing with primes using scala language. Draw Ulam spiral, ...
Scala
7
star
10

zio-worksheet

Simplified ZIO user experience in REPL, worksheet or script contexts
Scala
6
star
11

bootstrap

scala script bootstrap mechanism with #include support
Scala
6
star
12

the-weakest-link

Scala
4
star
13

custom-collection

Custom scala collection examples
Scala
4
star
14

scala-dummy-project

scala dummy project with standalone executable jar
Shell
3
star
15

drools-scripting

Drools made easy to use for scripting or testing purposes
Scala
2
star
16

codingame-with-scalakit-example

codingame scalakit example using git submodule to reference the scalakit
Scala
2
star
17

simple-plugin-architecture

Scala simple plugin architecture (with plugin automatic compilation if required)
Scala
2
star
18

exproxy

a 2005 personal project...
Java
2
star
19

cntlm

dockerized cntlm
Shell
2
star
20

primes-scalatra-app

Scala
1
star
21

naturalsort

scala naturalsort algorithm
Scala
1
star
22

web-echo

A websocket/webhook JSON data recorder with API
Scala
1
star
23

akka-sandbox

temporary project to test and learn AKKA 2
Scala
1
star
24

advent-of-code-2023

Scala
1
star
25

bullyboy

sha1 brute force attack
Scala
1
star
26

the-rules-for-good-code-examples

Several rules to write the best possible source code examples
1
star
27

data-recorder

Scala
1
star
28

advent-of-code-2020

Scala
1
star
29

jenkins-phantomjs-slave

jenkins slave with phantomjs 1.9 docker image
1
star
30

dock-primesui

Shell
1
star
31

jenkins

Jenkins docker image
Shell
1
star