Giter VIP home page Giter VIP logo

kossh's Introduction

KOSSH - Kotlin SSH API

High level Kotlin SSH API for easy and fast operations on remote servers. This is a Kotlin port of the Scala JASSH library.

The API is JSCH based.


Hello World script

It requires a local user named "test" with password "testing", 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 kossh.jar "$0" "$@"
!#
kossh.impl.SSH.once("localhost", "test", "testing") { 
  print(execute("""echo "Hello World from $(hostname)" """))
}

Persisted shell session

#!/bin/sh
exec java -jar kossh.jar "$0" "$@"
!#
kossh.impl.SSH.shell("localhost", "test", "testtest") {
  println("initial directory is $pwd")
  cd("/tmp")
  println("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 kossh.impl.*

val settings = SSHOptions(host = host, username=user, password = pass, prompt = 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

kossh's People

Contributors

jkelly467 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.