Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Commit

Permalink
Add support for authorized_keys files.
Browse files Browse the repository at this point in the history
Each user can have a set of authorized keys for public key authentication.
This is better to support as it lets us use different algorithms and not
just RSA. In the age of security, it's good to have variety.

I also added additional libraries to support ed25519-based public keys.

I updated the SSH libraries so any upstream bug fixes are applied, fixed
some warnings and a few other things.
  • Loading branch information
Justasic committed Oct 3, 2019
1 parent dc76da9 commit 0458179
Show file tree
Hide file tree
Showing 10 changed files with 382 additions and 254 deletions.
68 changes: 68 additions & 0 deletions .clangformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
#BasedOnStyle: WebKit
TabWidth: '4'
IndentWidth: '4'
UseTab: 'Always'
AlignOperands: 'true'
AlignAfterOpenBracket: 'Align'
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'true'
AlignEscapedNewlines: 'Left'
AlignTrailingComments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'true'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: 'All'
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterReturnType: 'None'
AlwaysBreakTemplateDeclarations: 'true'
AlwaysBreakBeforeMultilineStrings: 'false'
BinPackArguments: 'false'
BinPackParameters: 'false'
BreakBeforeBraces: 'Custom'
BraceWrapping:
AfterEnum: 'true'
AfterClass: 'true'
AfterControlStatement: 'true'
AfterStruct: 'true'
AfterFunction: 'true'
AfterNamespace: 'true'
AfterUnion: 'true'
AfterExternBlock: 'true'
BeforeCatch: 'true'
BeforeElse: 'true'
SplitEmptyRecord: 'false'
SplitEmptyNamespace: 'false'
SplitEmptyFunction: 'false'
BreakBeforeBinaryOperators: 'true'
BreakBeforeTernaryOperators: 'false'
BreakConstructorInitializersBeforeComma: 'false'
BreakBeforeInheritanceComma: 'false'
BreakStringLiterals: 'true'
ColumnLimit: '140'
CompactNamespaces: 'false'
Cpp11BracedListStyle: 'true'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'false'
DerivePointerAlignment: 'false'
IndentCaseLabels: 'true'
IndentPPDirectives: 'AfterHash'
KeepEmptyLinesAtTheStartOfBlocks: 'true'
Language: 'Java'
NamespaceIndentation: 'All'
PointerAlignment: 'Right'
ReflowComments: 'true'
SortIncludes: 'true'
SortUsingDeclarations: 'true'
SpaceAfterCStyleCast: 'false'
SpaceAfterTemplateKeyword: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: 'false'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'false'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
Standard: 'Auto'
...
68 changes: 66 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,70 @@
Bukkit-SSHD
Spigot-SSHD
===========

[![Build Status](https://travis-ci.org/rmichela/Bukkit-SSHD.png)](https://travis-ci.org/rmichela/Bukkit-SSHD)

An SSHD daemon embedded in a Bukkit plugin.
Have you ever wished you could remotely access your server's admin console without having to setup a complex remote access system? Now you can with SSHD.

SSHD securely exposes your Spigot admin console using the SSH protocol - the same protocol that serves as the secure foundation for nearly all remote server administration.

- Compatible with all ssh clients, regardless of operating system.
- Remotely view your server log in real-time.
- Remotely issue commands from the server console, just as if you were on the server itself.
- Supports multiple concurrent remote connections.
- Strong identity support using public key authentication.
- Remotely script your server by issuing one-off console commands with ssh.

## Why should I use SSHD?

- Your server runs on Windows.
- You are in a shared hosting environment that only gives you access to the - log files.
- You want to share access to your server console, but don't want to give anybody access to the machine its running on.
- You always wanted to use RCON, but want to see the server log as well.
- You are tired of running your server in a Screen session.
- You just want to access your server console using SSH.

## Configuration

- **listenAddress** - The network interface(s) SSHD should listen on. (Default all)
- **port** - Specify the port SSHD should listen on. (Default 22)
- **username/password** - The credentials used to log into the server console. (Default blank)

Note: By default, only public key authentication is enabled. This is the most secure authentication mode! Setting a username and password will make your server less secure.

## Setting Up Public Key Authentication

Setting up public key authentication with SSH requires first generating a public and private key pair and then installing just the public key on your Spigot server.

On Windows

1. TODO

On Linux/OS X

1. TODO

## Commands
None - just install and go.

## Permissions

None - SSHD uses cryptographic certificates or a secure username and password to verify remote access.

## Source Code
[Get the source on GitHub](https://github.com/Justasic/Bukkit-SSHD "Source Code")

## Metrics

This plugin utilizes Hidendra's plugin metrics system. the following information is collected and sent to mcstats.org unless opted out:

- A unique identifier
- The server's version of Java
- Whether the server is in offline or online mode
- Plugin's version
- Server's version
- OS version/name and architecture
- core count for the CPU
- Number of players online
- Metrics version

Opting out of this service can be done by editing plugins/Plugin Metrics/config.yml and changing opt-out to true.
53 changes: 42 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
<modelVersion>4.0.0</modelVersion>

<groupId>com.ryanmichela</groupId>
<artifactId>SSHD</artifactId>
<version>1.3.4.1</version>
<url>http://dev.bukkit.org/server-mods/sshd/</url>
<artifactId>sshd</artifactId>
<version>1.3.4.2</version>
<url>https://github.com/Justasic/Bukkit-SSHD/</url>

<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<!-- Repositories -->
<repositories>
Expand All @@ -30,33 +35,57 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<version>1.14.4-R0.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
<version>1.6.0</version>
<version>2.3.0</version>
<scope>compile</scope>
<type>jar</type>
</dependency>

<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-mina</artifactId>
<version>2.3.0</version>
</dependency>

<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-common</artifactId>
<version>2.3.0</version>
</dependency>

<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-sftp</artifactId>
<version>2.3.0</version>
</dependency>

<dependency>
<groupId>net.i2p.crypto</groupId>
<artifactId>eddsa</artifactId>
<version>0.3.0</version>
</dependency>

<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
<version>2.0.16</version>
<version>2.1.3</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
<version>1.7.28</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.25</version>
<version>1.7.28</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -85,10 +114,12 @@
<version>1.10</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencies>

<!-- Build -->
<build>
<defaultGoal>clean package</defaultGoal>

<resources>
<resource>
<targetPath>.</targetPath>
Expand All @@ -104,7 +135,7 @@
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -126,7 +157,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/com/ryanmichela/sshd/ConsoleCommandFactory.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.ryanmichela.sshd;

import org.apache.sshd.server.Command;
import org.apache.sshd.server.CommandFactory;
import org.apache.sshd.server.command.Command;
import org.apache.sshd.server.command.CommandFactory;
import org.apache.sshd.server.channel.ChannelSession;
import org.apache.sshd.server.Environment;
import org.apache.sshd.server.ExitCallback;
import org.bukkit.Bukkit;
Expand All @@ -16,7 +17,7 @@
public class ConsoleCommandFactory implements CommandFactory {

@Override
public Command createCommand(String command) {
public Command createCommand(ChannelSession cs, String command) {
return new ConsoleCommand(command);
}

Expand Down Expand Up @@ -50,7 +51,7 @@ public void setExitCallback(ExitCallback callback) {
}

@Override
public void start(Environment environment) throws IOException {
public void start(ChannelSession cs, Environment environment) throws IOException {
try {
SshdPlugin.instance.getLogger()
.info("[U: " + environment.getEnv().get(Environment.ENV_USER) + "] " + command);
Expand All @@ -63,8 +64,6 @@ public void start(Environment environment) throws IOException {
}

@Override
public void destroy() {

}
}
public void destroy(ChannelSession cn) {}
}
}
Loading

0 comments on commit 0458179

Please sign in to comment.