Compare commits
6 Commits
feature/wh
...
1.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a9a5245b9 | ||
|
|
396351771c | ||
|
|
f034cef465 | ||
|
|
956f0cc3ef | ||
|
|
027605e743 | ||
|
|
be9c53bf6f |
61
pom.xml
61
pom.xml
@@ -6,14 +6,14 @@
|
|||||||
|
|
||||||
<groupId>com.ryanmichela</groupId>
|
<groupId>com.ryanmichela</groupId>
|
||||||
<artifactId>SSHD</artifactId>
|
<artifactId>SSHD</artifactId>
|
||||||
<version>1.1</version>
|
<version>1.3</version>
|
||||||
<url>http://dev.bukkit.org/server-mods/sshd/</url>
|
<url>http://dev.bukkit.org/server-mods/sshd/</url>
|
||||||
|
|
||||||
<!-- Repositories -->
|
<!-- Repositories -->
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>bukkit-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>http://repo.bukkit.org/content/groups/public/</url>
|
<url>https://hub.spigotmc.org/nexus/content/groups/public</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
@@ -30,27 +30,65 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>craftbukkit</artifactId>
|
<artifactId>craftbukkit</artifactId>
|
||||||
<version>1.7.9-R0.2</version>
|
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>system</scope>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
|
<systemPath>${basedir}/bukkit-build/bukkit.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.sshd</groupId>
|
<groupId>org.apache.sshd</groupId>
|
||||||
<artifactId>sshd-core</artifactId>
|
<artifactId>sshd-core</artifactId>
|
||||||
<version>0.9.0</version>
|
<version>1.6.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.mina</groupId>
|
||||||
|
<artifactId>mina-core</artifactId>
|
||||||
|
<version>2.0.16</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
<version>1.7.25</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-jdk14</artifactId>
|
||||||
|
<version>1.7.25</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<!-- Build -->
|
<!-- Build -->
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<!-- Shade plugin -->
|
|
||||||
<plugin>
|
<plugin>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>single</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<descriptorRefs>
|
||||||
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
|
</descriptorRefs>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Shade plugin -->
|
||||||
|
<!-- <plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>1.5</version>
|
<version>1.7</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
@@ -72,15 +110,16 @@
|
|||||||
</filters>
|
</filters>
|
||||||
<minimizeJar>true</minimizeJar>
|
<minimizeJar>true</minimizeJar>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin> -->
|
||||||
|
|
||||||
<!-- Compile plugin -->
|
<!-- Compile plugin -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.0</version>
|
<version>3.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.8</source>
|
||||||
<target>1.6</target>
|
<target>1.8</target>
|
||||||
<showDeprecation>true</showDeprecation>
|
<showDeprecation>true</showDeprecation>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.ryanmichela.sshd;
|
package com.ryanmichela.sshd;
|
||||||
|
|
||||||
import org.apache.sshd.server.PasswordAuthenticator;
|
import org.apache.sshd.server.auth.password.PasswordAuthenticator;
|
||||||
import org.apache.sshd.server.session.ServerSession;
|
import org.apache.sshd.server.session.ServerSession;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ import java.io.OutputStream;
|
|||||||
import java.util.logging.StreamHandler;
|
import java.util.logging.StreamHandler;
|
||||||
|
|
||||||
public class ConsoleShellFactory implements Factory<Command> {
|
public class ConsoleShellFactory implements Factory<Command> {
|
||||||
|
public Command get() {
|
||||||
|
return this.create();
|
||||||
|
}
|
||||||
|
|
||||||
public Command create() {
|
public Command create() {
|
||||||
return new ConsoleShell();
|
return new ConsoleShell();
|
||||||
@@ -92,7 +95,7 @@ public class ConsoleShellFactory implements Factory<Command> {
|
|||||||
String command;
|
String command;
|
||||||
try {
|
try {
|
||||||
printPreamble(consoleReader);
|
printPreamble(consoleReader);
|
||||||
while(true) {
|
while (true) {
|
||||||
command = consoleReader.readLine("\r>", null);
|
command = consoleReader.readLine("\r>", null);
|
||||||
if (command != null) {
|
if (command != null) {
|
||||||
if (command.equals("exit")) {
|
if (command.equals("exit")) {
|
||||||
@@ -109,7 +112,7 @@ public class ConsoleShellFactory implements Factory<Command> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printPreamble(ConsoleReader consoleReader) throws IOException{
|
private void printPreamble(ConsoleReader consoleReader) throws IOException {
|
||||||
consoleReader.println(" _____ _____ _ _ _____");
|
consoleReader.println(" _____ _____ _ _ _____");
|
||||||
consoleReader.println(" / ____/ ____| | | | __ \\");
|
consoleReader.println(" / ____/ ____| | | | __ \\");
|
||||||
consoleReader.println("| (___| (___ | |__| | | | |");
|
consoleReader.println("| (___| (___ | |__| | | | |");
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.ryanmichela.sshd;
|
|||||||
import org.apache.sshd.common.SshException;
|
import org.apache.sshd.common.SshException;
|
||||||
import org.bukkit.craftbukkit.libs.jline.console.ConsoleReader;
|
import org.bukkit.craftbukkit.libs.jline.console.ConsoleReader;
|
||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.ryanmichela.sshd;
|
package com.ryanmichela.sshd;
|
||||||
|
|
||||||
import org.apache.mina.util.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@@ -22,7 +22,7 @@ public class PemDecoder extends java.io.BufferedReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PublicKey getPemBytes() throws Exception {
|
public PublicKey getPemBytes() throws Exception {
|
||||||
StringBuffer b64 = new StringBuffer();
|
StringBuilder b64 = new StringBuilder();
|
||||||
|
|
||||||
String line = readLine();
|
String line = readLine();
|
||||||
if (!line.matches(BEGIN)) {
|
if (!line.matches(BEGIN)) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.ryanmichela.sshd;
|
package com.ryanmichela.sshd;
|
||||||
|
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.sshd.server.PublickeyAuthenticator;
|
import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
|
||||||
import org.apache.sshd.server.session.ServerSession;
|
import org.apache.sshd.server.session.ServerSession;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|||||||
@@ -28,9 +28,7 @@ public class ReflectionUtil {
|
|||||||
modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL);
|
modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL);
|
||||||
|
|
||||||
f.set(o, newValue);
|
f.set(o, newValue);
|
||||||
} catch (NoSuchFieldException ex) {
|
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
||||||
System.out.println("*** " + c.getName() + ":" + ex);
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
System.out.println("*** " + c.getName() + ":" + ex);
|
System.out.println("*** " + c.getName() + ":" + ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.ryanmichela.sshd;
|
package com.ryanmichela.sshd;
|
||||||
|
|
||||||
import org.apache.sshd.SshServer;
|
import org.apache.sshd.server.SshServer;
|
||||||
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
|
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
@@ -35,11 +35,13 @@ public class SshdPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
sshd = SshServer.setUpDefaultServer();
|
sshd = SshServer.setUpDefaultServer();
|
||||||
sshd.setPort(getConfig().getInt("port", 22));
|
sshd.setPort(getConfig().getInt("port", 22));
|
||||||
|
String host = getConfig().getString("listenAddress", "all");
|
||||||
|
sshd.setHost(host.equals("all") ? null : host);
|
||||||
|
|
||||||
File hostKey = new File(getDataFolder(), "hostkey");
|
File hostKey = new File(getDataFolder(), "hostkey");
|
||||||
File authorizedKeys = new File(getDataFolder(), "authorized_keys");
|
File authorizedKeys = new File(getDataFolder(), "authorized_keys");
|
||||||
|
|
||||||
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(hostKey.getPath()));
|
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(hostKey));
|
||||||
sshd.setShellFactory(new ConsoleShellFactory());
|
sshd.setShellFactory(new ConsoleShellFactory());
|
||||||
sshd.setPasswordAuthenticator(new ConfigPasswordAuthenticator());
|
sshd.setPasswordAuthenticator(new ConfigPasswordAuthenticator());
|
||||||
sshd.setPublickeyAuthenticator(new PublicKeyAuthenticator(authorizedKeys));
|
sshd.setPublickeyAuthenticator(new PublicKeyAuthenticator(authorizedKeys));
|
||||||
|
|||||||
@@ -25,15 +25,18 @@ public class StreamHandlerAppender implements Appender {
|
|||||||
@Override
|
@Override
|
||||||
public void append(LogEvent logEvent) {
|
public void append(LogEvent logEvent) {
|
||||||
java.util.logging.Level level;
|
java.util.logging.Level level;
|
||||||
switch (logEvent.getLevel())
|
|
||||||
{
|
|
||||||
case DEBUG: level = java.util.logging.Level.FINE; break;
|
|
||||||
case INFO: level = java.util.logging.Level.INFO; break;
|
|
||||||
case WARN: level = java.util.logging.Level.WARNING; break;
|
|
||||||
case ERROR: level = java.util.logging.Level.SEVERE; break;
|
|
||||||
default: level = java.util.logging.Level.INFO; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(logEvent.getLevel().equals(org.apache.logging.log4j.Level.DEBUG)) {
|
||||||
|
level = java.util.logging.Level.FINE;
|
||||||
|
} else if(logEvent.getLevel().equals(org.apache.logging.log4j.Level.INFO)) {
|
||||||
|
level = java.util.logging.Level.INFO;
|
||||||
|
} else if(logEvent.getLevel().equals(org.apache.logging.log4j.Level.WARN)) {
|
||||||
|
level = java.util.logging.Level.WARNING;
|
||||||
|
} else if(logEvent.getLevel().equals(org.apache.logging.log4j.Level.ERROR)) {
|
||||||
|
level = java.util.logging.Level.SEVERE;
|
||||||
|
} else {
|
||||||
|
level = java.util.logging.Level.INFO;
|
||||||
|
}
|
||||||
String message = logEvent.getMessage().getFormattedMessage();
|
String message = logEvent.getMessage().getFormattedMessage();
|
||||||
|
|
||||||
|
|
||||||
@@ -66,6 +69,16 @@ public class StreamHandlerAppender implements Appender {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public State getState() {
|
||||||
|
return State.INITIALIZED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
|
|
||||||
@@ -80,4 +93,9 @@ public class StreamHandlerAppender implements Appender {
|
|||||||
public boolean isStarted() {
|
public boolean isStarted() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isStopped() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,7 @@ public class PluginSlf4jFactory implements ILoggerFactory {
|
|||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private boolean isEnabled(Level level) {
|
private boolean isEnabled(Level level) {
|
||||||
if (SshdPlugin.instance != null) {
|
return SshdPlugin.instance != null && SshdPlugin.instance.getLogger().isLoggable(level);
|
||||||
return SshdPlugin.instance.getLogger().isLoggable(level);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void log(Level level, String s, Object[] objects) {
|
private void log(Level level, String s, Object[] objects) {
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
# This is the port the SSH server will listen on.
|
# The IP addresses(s) the SSH server will listen on. Use a comma separated list for multiple addresses.
|
||||||
|
# Leave as "all" for all addresses.
|
||||||
|
listenAddress: all
|
||||||
|
# The port the SSH server will listen on.
|
||||||
port: 22
|
port: 22
|
||||||
|
|
||||||
# By default, only public key authentication is enabled. This is the most secure mode.
|
# By default, only public key authentication is enabled. This is the most secure mode.
|
||||||
@@ -9,4 +12,4 @@ port: 22
|
|||||||
# For less secure username and password based authentication, complete the sections below.
|
# For less secure username and password based authentication, complete the sections below.
|
||||||
credentials:
|
credentials:
|
||||||
# user1: password1
|
# user1: password1
|
||||||
# user2: password2
|
# user2: password2
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name: SSHD
|
name: SSHD
|
||||||
version: "1.1"
|
version: "1.2"
|
||||||
author: Ryan Michela
|
author: Ryan Michela
|
||||||
main: com.ryanmichela.sshd.SshdPlugin
|
main: com.ryanmichela.sshd.SshdPlugin
|
||||||
Reference in New Issue
Block a user