Skip to content

Commit 9eb4d96

Browse files
committed
completed readline examples
1 parent c80b37f commit 9eb4d96

File tree

18 files changed

+6634
-0
lines changed

18 files changed

+6634
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Compiled class file
22
*.class
33

4+
target/
5+
46
# Log file
57
*.log
68

readline/shell-ssh/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Æsh Readline Shell SSH
2+
3+
In this example we're reusing [ShellExample] (../shell), but instead of using `TerminalConnection`
4+
we're setting up a SSH server connection listening on port 5000.
5+
6+
To connect to it:
7+
> ssh username@localhost -p 5000
8+
9+
## Requirements
10+
11+
To compile and run you need
12+
- JDK 8 or later
13+
- Apache Maven `3.5.+`
14+
15+
## Building
16+
17+
Launch the Maven build with:
18+
19+
> mvn install
20+
21+
## Running
22+
23+
For simplicity we use the Maven shade plugin to package all the dependencies into on jar, to run:
24+
25+
> java -jar target/shell-ssh-0.1.jar
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.acme</groupId>
5+
<artifactId>shell-ssh</artifactId>
6+
<version>0.1</version>
7+
<build>
8+
<plugins>
9+
<plugin>
10+
<artifactId>maven-compiler-plugin</artifactId>
11+
<version>${compiler-plugin.version}</version>
12+
</plugin>
13+
<plugin>
14+
<artifactId>maven-jar-plugin</artifactId>
15+
<version>${jar-plugin.version}</version>
16+
<executions>
17+
<execution>
18+
<goals>
19+
<goal>test-jar</goal>
20+
</goals>
21+
</execution>
22+
</executions>
23+
<configuration>
24+
<archive>
25+
<manifest>
26+
<addClasspath>true</addClasspath>
27+
<mainClass>org.acme.shellssh.SSHShellExample</mainClass>
28+
</manifest>
29+
</archive>
30+
</configuration>
31+
</plugin>
32+
<plugin>
33+
<artifactId>maven-shade-plugin</artifactId>
34+
<version>${shade-plugin.version}</version>
35+
<executions>
36+
<execution>
37+
<phase>package</phase>
38+
<goals>
39+
<goal>shade</goal>
40+
</goals>
41+
<configuration>
42+
<artifactSet>
43+
<excludes>
44+
<exclude>org.fusesource.jansi:jansi</exclude>
45+
<exclude>org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-depchain</exclude>
46+
<exclude>junit:junit</exclude>
47+
</excludes>
48+
</artifactSet>
49+
</configuration>
50+
</execution>
51+
</executions>
52+
</plugin>
53+
</plugins>
54+
</build>
55+
<properties>
56+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
57+
<shade-plugin.version>3.2.1</shade-plugin.version>
58+
<readline.version>1.17</readline.version>
59+
<jar-plugin.version>3.1.1</jar-plugin.version>
60+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
61+
<maven.compiler.source>1.8</maven.compiler.source>
62+
<compiler-plugin.version>3.8.0</compiler-plugin.version>
63+
<maven.compiler.target>1.8</maven.compiler.target>
64+
</properties>
65+
</project>

readline/shell-ssh/hostkey.ser

1.89 KB
Binary file not shown.

readline/shell-ssh/pom.xml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ JBoss, Home of Professional Open Source
4+
~ Copyright 2014 Red Hat Inc. and/or its affiliates and other contributors
5+
~ as indicated by the @authors tag. All rights reserved.
6+
~ See the copyright.txt in the distribution for a
7+
~ full listing of individual contributors.
8+
~
9+
~ Licensed under the Apache License, Version 2.0 (the "License");
10+
~ you may not use this file except in compliance with the License.
11+
~ You may obtain a copy of the License at
12+
~ http://www.apache.org/licenses/LICENSE-2.0
13+
~ Unless required by applicable law or agreed to in writing, software
14+
~ distributed under the License is distributed on an "AS IS" BASIS,
15+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
~ See the License for the specific language governing permissions and
17+
~ limitations under the License.
18+
-->
19+
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
22+
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<groupId>org.acme</groupId>
26+
<artifactId>shell-ssh</artifactId>
27+
<packaging>jar</packaging>
28+
<version>0.1</version>
29+
30+
<properties>
31+
<readline.version>1.17</readline.version>
32+
33+
<!-- maven plugin versions -->
34+
<compiler-plugin.version>3.8.0</compiler-plugin.version>
35+
<jar-plugin.version>3.1.1</jar-plugin.version>
36+
<shade-plugin.version>3.2.1</shade-plugin.version>
37+
38+
<maven.compiler.target>1.8</maven.compiler.target>
39+
<maven.compiler.source>1.8</maven.compiler.source>
40+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
41+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
42+
</properties>
43+
44+
45+
<dependencies>
46+
<dependency>
47+
<groupId>org.aesh</groupId>
48+
<artifactId>aesh-readline</artifactId>
49+
<version>${readline.version}</version>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.aesh</groupId>
53+
<artifactId>aesh-terminal-ssh</artifactId>
54+
<version>${readline.version}</version>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.apache.mina</groupId>
58+
<artifactId>mina-core</artifactId>
59+
<version>2.0.9</version>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.apache.sshd</groupId>
63+
<artifactId>sshd-core</artifactId>
64+
<version>1.0.0</version>
65+
<optional>true</optional>
66+
<exclusions>
67+
<exclusion>
68+
<groupId>org.slf4j</groupId>
69+
<artifactId>slf4j-api</artifactId>
70+
</exclusion>
71+
</exclusions>
72+
</dependency>
73+
74+
<dependency>
75+
<groupId>org.acme</groupId>
76+
<artifactId>shell</artifactId>
77+
<version>${project.version}</version>
78+
</dependency>
79+
80+
</dependencies>
81+
82+
<build>
83+
<plugins>
84+
<plugin>
85+
<groupId>org.apache.maven.plugins</groupId>
86+
<artifactId>maven-compiler-plugin</artifactId>
87+
<version>${compiler-plugin.version}</version>
88+
</plugin>
89+
<plugin>
90+
<groupId>org.apache.maven.plugins</groupId>
91+
<artifactId>maven-jar-plugin</artifactId>
92+
<version>${jar-plugin.version}</version>
93+
<configuration>
94+
<archive>
95+
<manifest>
96+
<addClasspath>true</addClasspath>
97+
<mainClass>org.acme.shellssh.SSHShellExample</mainClass>
98+
</manifest>
99+
</archive>
100+
</configuration>
101+
<executions>
102+
<execution>
103+
<goals>
104+
<goal>test-jar</goal>
105+
</goals>
106+
</execution>
107+
</executions>
108+
</plugin>
109+
<plugin>
110+
<groupId>org.apache.maven.plugins</groupId>
111+
<artifactId>maven-shade-plugin</artifactId>
112+
<version>${shade-plugin.version}</version>
113+
<executions>
114+
<execution>
115+
<phase>package</phase>
116+
<goals>
117+
<goal>shade</goal>
118+
</goals>
119+
<configuration>
120+
<artifactSet>
121+
<excludes>
122+
<exclude>org.fusesource.jansi:jansi</exclude>
123+
<exclude>org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-depchain</exclude>
124+
<exclude>junit:junit</exclude>
125+
</excludes>
126+
</artifactSet>
127+
</configuration>
128+
</execution>
129+
</executions>
130+
</plugin>
131+
</plugins>
132+
</build>
133+
134+
135+
136+
</project>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* JBoss, Home of Professional Open Source
3+
* Copyright 2017 Red Hat Inc. and/or its affiliates and other contributors
4+
* as indicated by the @authors tag. All rights reserved.
5+
* See the copyright.txt in the distribution for a
6+
* full listing of individual contributors.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package org.acme.shellssh;
21+
22+
import org.aesh.terminal.ssh.netty.NettySshTtyBootstrap;
23+
import org.apache.sshd.server.keyprovider.AbstractGeneratorHostKeyProvider;
24+
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
25+
26+
import java.io.File;
27+
import java.util.concurrent.TimeUnit;
28+
29+
import org.acme.shell.ShellExample;
30+
31+
/**
32+
* @author <a href="mailto:[email protected]">Ståle W. Pedersen</a>
33+
*/
34+
public class SSHShellExample {
35+
36+
public static synchronized void main(String[] args) throws Exception {
37+
38+
AbstractGeneratorHostKeyProvider hostKeyProvider =
39+
new SimpleGeneratorHostKeyProvider( new File("hostkey.ser").toPath());
40+
hostKeyProvider.setAlgorithm("RSA");
41+
NettySshTtyBootstrap bootstrap = new NettySshTtyBootstrap().
42+
setPort(5000).
43+
setHost("localhost")
44+
.setKeyPairProvider(hostKeyProvider)
45+
//.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("/tmp/mysample").toPath()))
46+
47+
;
48+
bootstrap.start(new ShellExample()).get(10, TimeUnit.SECONDS);
49+
System.out.println("SSH started on localhost:5000");
50+
SSHShellExample.class.wait();
51+
}
52+
}

readline/shell-telnet/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Æsh Readline Shell Telnet
2+
3+
In this example we're reusing [ShellExample] (../shell), but instead of using `TerminalConnection`
4+
we're setting up a Telnet server connection listening on port 4000.
5+
6+
To connect to it:
7+
> telnet localhost 4000
8+
9+
## Requirements
10+
11+
To compile and run you need
12+
- JDK 8 or later
13+
- Apache Maven `3.5.+`
14+
15+
## Building
16+
17+
Launch the Maven build with:
18+
19+
> mvn install
20+
21+
## Running
22+
23+
For simplicity we use the Maven shade plugin to package all the dependencies into on jar, to run:
24+
25+
> java -jar target/shell-telnet-0.1.jar
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.acme</groupId>
5+
<artifactId>shell-telnet</artifactId>
6+
<version>0.1</version>
7+
<build>
8+
<plugins>
9+
<plugin>
10+
<artifactId>maven-compiler-plugin</artifactId>
11+
<version>${compiler-plugin.version}</version>
12+
</plugin>
13+
<plugin>
14+
<artifactId>maven-jar-plugin</artifactId>
15+
<version>${jar-plugin.version}</version>
16+
<executions>
17+
<execution>
18+
<goals>
19+
<goal>test-jar</goal>
20+
</goals>
21+
</execution>
22+
</executions>
23+
<configuration>
24+
<archive>
25+
<manifest>
26+
<addClasspath>true</addClasspath>
27+
<mainClass>org.acme.shelltelnet.TelnetShellExample</mainClass>
28+
</manifest>
29+
</archive>
30+
</configuration>
31+
</plugin>
32+
<plugin>
33+
<artifactId>maven-shade-plugin</artifactId>
34+
<version>${shade-plugin.version}</version>
35+
<executions>
36+
<execution>
37+
<phase>package</phase>
38+
<goals>
39+
<goal>shade</goal>
40+
</goals>
41+
<configuration>
42+
<artifactSet>
43+
<excludes>
44+
<exclude>org.fusesource.jansi:jansi</exclude>
45+
<exclude>org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-depchain</exclude>
46+
<exclude>junit:junit</exclude>
47+
</excludes>
48+
</artifactSet>
49+
</configuration>
50+
</execution>
51+
</executions>
52+
</plugin>
53+
</plugins>
54+
</build>
55+
<properties>
56+
<shade-plugin.version>3.2.1</shade-plugin.version>
57+
<netty.version>4.0.31.Final</netty.version>
58+
<jar-plugin.version>3.1.1</jar-plugin.version>
59+
<compiler-plugin.version>3.8.0</compiler-plugin.version>
60+
<readline.version>1.17</readline.version>
61+
<maven.compiler.target>1.8</maven.compiler.target>
62+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
63+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
64+
<maven.compiler.source>1.8</maven.compiler.source>
65+
</properties>
66+
</project>

readline/shell-telnet/hostkey.ser

1.89 KB
Binary file not shown.

0 commit comments

Comments
 (0)