项目作者: jkelly467

项目描述 :
Kotlin SSH Client library
高级语言: Kotlin
项目地址: git://github.com/jkelly467/kossh.git
创建时间: 2018-07-27T15:24:03Z
项目社区:https://github.com/jkelly467/kossh

开源协议:

下载


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.

  1. #!/bin/sh
  2. exec java -jar kossh.jar "$0" "$@"
  3. !#
  4. kossh.impl.SSH.once("localhost", "test", "testing") {
  5. print(execute("""echo "Hello World from $(hostname)" """))
  6. }

Persisted shell session

  1. #!/bin/sh
  2. exec java -jar kossh.jar "$0" "$@"
  3. !#
  4. kossh.impl.SSH.shell("localhost", "test", "testtest") {
  5. println("initial directory is $pwd")
  6. cd("/tmp")
  7. println("now it is $pwd")
  8. }

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

  1. import kossh.impl.*
  2. val settings = SSHOptions(host = host, username=user, password = pass, prompt = prompt, timeout = timeout)
  3. val session = SSH(settings)
  4. val shell = session.newPowerShell()
  5. println(shell.ls())
  6. println(shell.pwd())

SSH Configuration notes

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

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

AIX SSHD CONFIGURATION :

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

LINUX SSHD CONFIGURATION

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

SOLARIS SSHD CONFIGURATION

  1. vi /usr/local/etc/ssh/sshd_config
  2. svcadm restart ssh

MAC OS X CONFIGURATION

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