Simple ssh server and client with examples how to use it. Implementation uses Apache Mina project. Server supports following clients:
- ssh terminals - like putty or 'OpenSSH SSH client', providing REPL interface.
- ssh commands - single commands send using 'OpenSSH SSH client'
- java client - 'ssh-java' client library for connection from java runtime
- ssh-server - versatile library for embedding ssh server into Java applications.
- ssh-client - versatile library for embedding ssh client into Java applications.
- ssh-examples - examples of use for ssh-server and ssh-client.
- use dependencies
<dependency> <groupId>itx.ssh.server</groupId> <artifactId>ssh-server</artifactId> <version>1.0.0</version> </dependency>
compile 'itx.ssh.server:ssh-server:1.0.0'
- start server
- override CommandProcessors
- use dependencies
<dependency> <groupId>itx.ssh.client</groupId> <artifactId>ssh-client</artifactId> <version>1.0.0</version> </dependency>
compile 'itx.ssh.client:ssh-client:1.0.0'
- start client
- send and receive messages
This command will compile project, run the tests, localy publish maven artifacts and create ssh-examples distribution.
gradle clean build publishToMavenLocal installDist distZip
After build is done, server can be started from commandline, listening on port 2222.
./ssh-examples/build/install/ssh-examples/bin/ssh-examples
In this mode, ssh client connects to running server and gets REPL interface. Example application implements supported commands for reference.
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null user@localhost -p 2222
ssh user@localhost -p 2222
After client is connected, it may send supported commands via terminal. 'exit' command closes the session.
In this mode, ssh client will send separate commands to running server. Example application implements supported commands for reference.
sshpass -p secret ssh user@localhost -p 2222 "set 22"
sshpass -p secret ssh user@localhost -p 2222 "get"
In this mode, ssh-client library may be used to conect to runnig instance of ssh-server.
- get - will get internal state
- set <value> - will set internal state to given value