2 Commits

Author SHA1 Message Date
Justin Crawford
0afba39d57 This should actually fix rmichela#10 2019-10-06 02:58:52 -07:00
Justin Crawford
1b4c7c2304 Update readme as it's wildly out of date 2019-10-06 01:07:39 -07:00
7 changed files with 82 additions and 62 deletions

View File

@@ -12,59 +12,77 @@ SSHD securely exposes your Spigot admin console using the SSH protocol - the sam
- 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.
- Audit history who is running commands in the console
- Run Spigot without using screen or tmux (by adding `-noconsole`)
- Remotely script your server by issuing one-off console commands with ssh.
## Why should I use SSHD?
### 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 are tired of running your server in a GNU screen or tmux 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
====================================
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.
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. This plugin supports all modern SSH key algoritms as OpenSSH. You can paste as many public keys from the methods below into each user's authorization file if they have multiple private keys. You can read [this guide from ssh.com](https://www.ssh.com/ssh/keygen/) if you want a better explanation on different key files.
On Windows
## Generating New Keys
1. TODO
#### On Windows
On Linux/OS X
1. Ensure [Putty](https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html) is installed and open up `puttygen` (you can search for it in start search).
2. Click `Generate` and follow the directions.
3. When it finishes, set your key comment (if you like) and copy the text from the big `Public key for pasting into OpenSSH authorized_keys file`
4. Create a new file inside of the `plugins/SSHD/authorized_users` folder and name the file just the username (example: `justasic`, there should ***NOT*** be a file extension or authentication does not work).
5. Paste the key you copied from step 3 into the file you just created.
6. SSH into the server and see if your key works
1. TODO
#### On Linux/OS X
1. Open a terminal and run `ssh-keygen` then follow the prompts.
2. Copy the contents of your `id_<algorithm>.pub` file (example: if your key was generated with rsa, it will be named `id_rsa.pub`). This file is usually located in `/home/YOURUSERNAME/.ssh/`
3. Paste the contents of the .pub file into a new file inside the `plugins/SSHD/authorized_users` folder and name the file just the username that the user will use to login with (example: `justasic`, there should ***NOT*** be a file extension or authentication does not work).
## Using existing keys
#### On Windows
1. Ensure [Putty](https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html) is installed and open up `puttygen` (you can search for it in start search).
2. Click `Conversions` then click `Import Key` and select your .ppk file.
3. Copy the text from the big `Public key for pasting into OpenSSH authorized_keys file`
4. Create a new file inside of the `plugins/SSHD/authorized_users` folder and name the file just the username (example: `justasic`, there should ***NOT*** be a file extension or authentication does not work).
5. Paste the key you copied from step 3 into the file you just created.
6. SSH into the server and see if your key works
#### On Linux/OS X
1. Copy the contents of your `id_<algorithm>.pub` file (example: if your key was generated with rsa, it will be named `id_rsa.pub`). This file is usually located in `/home/YOURUSERNAME/.ssh/`
2. Paste the contents of the .pub file into a new file inside the `plugins/SSHD/authorized_users` folder and name the file just the username that the user will use to login with (example: `justasic`, there should ***NOT*** be a file extension or authentication does not work).
Plugin Usage
============
## Commands
None - just install and go.
/mkpasswd <hash|help> <password>
mkpasswd supports the following hash algorithms:
- bcrypt - Using the OpenBSD-style Blowfish password hash
- sha256 - Using a basic salted sha256 hash
- pbkdf2 - Using the [PBKDF2](https://en.wikipedia.org/wiki/Pbkdf2) password hash
- PLAIN - Using plain text passwords (very insecure)
## Permissions
None - SSHD uses cryptographic certificates or a secure username and password to verify remote access.
`sshd.mkpasswd` - Checks if the in-game user has access to run the mkpasswd command.
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/Spigot-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.

View File

@@ -6,7 +6,7 @@
<groupId>com.ryanmichela</groupId>
<artifactId>sshd</artifactId>
<version>1.3.6</version>
<version>1.3.6.1</version>
<url>https://github.com/Justasic/Bukkit-SSHD/</url>
<properties>
@@ -171,4 +171,4 @@
</build>
<packaging>jar</packaging>
</project>
</project>

View File

@@ -67,8 +67,7 @@ public class ConsoleLogFormatter extends Formatter {
return result;
}
public
String format(LogRecord logrecord)
public String format(LogRecord logrecord)
{
try
{

View File

@@ -138,7 +138,7 @@ public class ConsoleShellFactory implements ShellFactory {
this.ConsoleReader.clearScreen();
continue;
}
// Hide the mkpasswd command input.
// Hide the mkpasswd command input from other users.
Boolean mkpasswd = command.split(" ")[0].equals("mkpasswd");
Bukkit.getScheduler().runTask(
@@ -153,17 +153,12 @@ public class ConsoleShellFactory implements ShellFactory {
else
{
if (!mkpasswd)
{
SshdPlugin.instance.getLogger().info("<" + this.Username + "> <" + (mkpasswd ? "True": "False") + "> " + command);
SshdPlugin.instance.getLogger().info("<" + this.Username + "> " + command);
}
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
}
});
}
// This should help stop one of the bugs where bytes are waiting to be written
// but the client fucked off already so the plugin throws an exception.
((Logger)LogManager.getRootLogger()).removeAppender(this.streamHandlerAppender);
}
catch (IOException e)
{

View File

@@ -1,49 +1,59 @@
package com.ryanmichela.sshd;
import org.apache.sshd.common.SshException;
import org.apache.sshd.common.channel.exception.SshChannelClosedException;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigInteger;
/**
* Copyright 2013 Ryan Michela
*/
public class FlushyOutputStream extends OutputStream {
public class FlushyOutputStream extends OutputStream
{
private OutputStream base;
private boolean isClosed = false;
public FlushyOutputStream(OutputStream base) {
public FlushyOutputStream(OutputStream base)
{
this.base = base;
}
@Override
public void write(int b) throws IOException {
if (isClosed) return;
base.write(b);
base.flush();
public void write(int b) throws IOException
{
this.write(BigInteger.valueOf(b).toByteArray());
}
@Override
public void write(byte[] b) throws IOException {
if (isClosed) return;
base.write(b);
base.flush();
public void write(byte[] b) throws IOException
{
this.write(b, 0, b.length);
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
if (isClosed) return;
try {
public void write(byte[] b, int off, int len) throws IOException
{
if (isClosed)
return;
try
{
base.write(b, off, len);
base.flush();
} catch (SshException e) {
if (!e.getMessage().contains("channel already closed")) throw e;
}
catch (SshChannelClosedException e)
{
// ignored.
}
}
@Override
public void close() {
public void close() throws IOException
{
isClosed = true;
base.close();
}
}

View File

@@ -39,7 +39,6 @@ class MkpasswdCommand implements CommandExecutor
// Dumb but whatever. Some people are really dense.
if (algoritm.equalsIgnoreCase("PLAIN"))
{
sender.sendMessage("Your hash: " + password);
// I mean c'mon...
sender.sendMessage("Bro really? it's literally your unencrypted password...");
}

View File

@@ -58,7 +58,6 @@ class SshdPlugin extends JavaPlugin
{
instance = this;
// pls comment this shit so I know what it does.
sshd = SshServer.setUpDefaultServer();
sshd.setPort(getConfig().getInt("Port", 1025));
String host = getConfig().getString("ListenAddress", "all");