-
Spring Boot支持集成一個稱為'CRaSH'的Java shell离赫。你可以在CRaSH中使用ssh或telnet命令連接到運(yùn)行的應(yīng)用。為了啟用遠(yuǎn)程shell支持译隘,你只需添加 spring-boot-starter-remote-shell 的依賴:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-remote-shell</artifactId> </dependency>
注:如果想使用telnet訪問丛肮,你還需添加對 org.crsh:crsh.shell.telnet 的依賴轩娶。
連接遠(yuǎn)程shell
-
默認(rèn)情況下,遠(yuǎn)程shell監(jiān)聽端口2000以等待連接沾凄。默認(rèn)用戶名為 user 梗醇,密碼為隨機(jī)生成的,并且在輸出日志中會顯示撒蟀。如果應(yīng)用使用Spring Security叙谨,該shell默認(rèn)使用相同的配置。如果不是保屯,將使用一個簡單的認(rèn)證策略手负,你可能會看到類似這樣的信息:
Using default password for shell access: ec03e16c-4cf4-49ee-b745-7c8255c1dd7e
Linux和OSX用戶可以使用 ssh 連接遠(yuǎn)程shell,Windows用戶可以下載并安裝PuTTY姑尺。
$ ssh -p 2000 user@localhost
user@localhost's password:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.0.BUILD-SNAPSHOT) on myhost
- 輸入help可以獲取一系列命令的幫助竟终。Spring boot提供 metrics , beans 切蟋, autoconfig 和 endpoint 命令统捶。
遠(yuǎn)程shell證書
- 你可以使用 shell.auth.simple.user.name 和 shell.auth.simple.user.password 屬性配置自定義的連接證書。也可以使用Spring Security的AuthenticationManager處理登錄職責(zé)柄粹。
擴(kuò)展遠(yuǎn)程shell
- 有很多有趣的方式可以用來擴(kuò)展遠(yuǎn)程shell喘鸟。