SSH Request Handler Plugin Module

Introduction

As you probably know, Bitbucket Server supports serving SCM hosting requests (i.e. pushes and pulls) over both HTTP/S and SSH. What you may not know is that Bitbucket Server supports another simple SSH command - whoami. If you have SSH enabled on your server and have uploaded your public key, try the following from the command line:

$ ssh -p 7999 your-bitbucket-server.example.com whoami

(Replace 7999 with the port that your Bitbucket Server server running Bitbucket Server)

You should get a simple response with your username:

tpettersen

Neat, huh? What's even cooler is the fact that these commands are pluggable. The whoami command is actually provided by a simple bundled plugin in Bitbucket Server. You can implement your own SSH command support using the SSH Request Handler plugin module.

See the javadoc for SshScmRequestHandler and SshScmRequest for more details on implementing support for a new SSH command.

Configuration

The root element for an SSH Request Handler plugin module is <ssh-request-handler/>. It allows the following attributes for configuration:

Attributes

Name Required Description Default
key The identifier of the plugin module. This key must be unique within the plugin where it is defined. N/A
class The fully qualified Java class name of the SSH request handler. This class must implement SshScmRequestHandler (don't worry about the 'Scm' in the name - non-SCM related commands are fine too). N/A

Example

Here is a simple atlassian-plugin.xml with a single SSH Request Handler module:

<atlassian-plugin name="My SSH Command Handler" key="example.plugin.mysshcommand" plugins-version="2">
    <plugin-info>
        <description>${project.description}</description>
        <version>${project.version}</version>
        <vendor name="${project.organization.name}" url="${project.organization.url}" />
    </plugin-info>

    <ssh-request-handler key="my-ssh-command" class="com.example.myplugin.MyCommandSshRequestHandler" />
</atlassian-plugin>