50. Monitoring and management using a remote shell (deprecated)

Spring Boot supports an integrated Java shell called ‘CRaSH’. You can use CRaSH to
ssh or telnet into your running application. To enable remote shell support, add
the following dependency to your project:

The remote shell is deprecated and will be removed in Spring Boot 2.0.

Tip

If you want to also enable telnet access you will additionally need a dependency
on org.crsh:crsh.shell.telnet.

Note

CRaSH requires to run with a JDK as it compiles commands on the fly. If a basic
help command fails, you are probably running with a JRE.

50.1 Connecting to the remote shell

By default the remote shell will listen for connections on port 2000. The default user
is user and the default password will be randomly generated and displayed in the log
output. If your application is using Spring Security, the shell will use
the same configuration by default. If not, a simple
authentication will be applied and you should see a message like this:

Type help for a list of commands. Spring Boot provides metrics, beans, autoconfig
and endpoint commands.

50.1.1 Remote shell credentials

You can use the management.shell.auth.simple.user.name and
management.shell.auth.simple.user.password properties to configure custom connection
credentials. It is also possible to use a ‘Spring Security’ AuthenticationManager to
handle login duties. See the
CrshAutoConfiguration
and ShellProperties
Javadoc for full details.

50.2 Extending the remote shell

The remote shell can be extended in a number of interesting ways.

50.2.1 Remote shell commands

You can write additional shell commands using Groovy (see the CRaSH documentation for details).
Due to limitations in CRaSH’s Java compiler, commands written in Java are not supported.
By default Spring Boot will search for commands in the following locations:

classpath*:/commands/**

classpath*:/crash/commands/**

Tip

You can change the search path by settings a shell.command-path-patterns property.

Note

If you are using an executable archive, any classes that a shell command depends
upon must be packaged in a nested jar rather than directly in the executable jar or war.

Here is a simple ‘hello’ command that could be loaded from
src/main/resources/commands/hello.groovy