<!DOCTYPE html>
< html lang = "zh-CN" >
< head >
< meta charset = "utf-8" >
< meta name = "viewport" content = "width=device-width,initial-scale=1" >
< meta name = "generator" content = "VuePress 2.0.0-beta.51" >
< style >
:root {
--c-bg: #fff;
}
html.dark {
--c-bg: #22272e;
}
html, body {
background-color: var(--c-bg);
}
< / style >
< script >
const userMode = localStorage.getItem('vuepress-color-scheme');
const systemDarkMode = window.matchMedia & & window.matchMedia('(prefers-color-scheme: dark)').matches;
if (userMode === 'dark' || (userMode !== 'light' & & systemDarkMode)) {
document.documentElement.classList.toggle('dark', true);
}
< / script >
< link rel = "icon" href = "/images/favicon.ico" > < meta name = "viewport" content = "width=device-width, initial-scale=1.0" > < meta property = "og:title" content = "Arthas" > < meta property = "og:image:alt" content = "Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas - alibaba/arthas: Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas" > < meta property = "og:image" content = "/images/arthas_mate_image.png" > < meta property = "og:description" content = "Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas - alibaba/arthas: Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas" > < meta property = "og:image:width" content = "1200" > < meta property = "og:image:height" content = "600" > < meta property = "twitter:image:src" content = "/images/arthas_mate_image.png" > < meta property = "twitter:image:alt" content = "Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas - alibaba/arthas: Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas" > < meta itemprop = "name" content = "Arthas" > < meta itemprop = "image" content = "/images/arthas_mate_image.png" > < meta itemprop = "description" content = "Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas - alibaba/arthas: Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas" > < script >
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?d5c5e25b100f0eb51a4c35c8a86ea9b4";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
< / script > < meta name = "aes-config" content = "pid=xux-opensource&user_type=101&uid=&username=&dim10=arthas" > < script src = "//g.alicdn.com/alilog/mlog/aplus_v2.js" id = "beacon-aplus" exparams = "clog=o&aplus&sidx=aplusSidx&ckx=aplusCkx" > < / script > < script src = "//g.alicdn.com/aes/??tracker/1.0.34/index.js,tracker-plugin-pv/2.4.5/index.js,tracker-plugin-event/1.2.5/index.js,tracker-plugin-jserror/1.0.13/index.js,tracker-plugin-api/1.1.14/index.js,tracker-plugin-perf/1.1.8/index.js,tracker-plugin-eventTiming/1.0.4/index.js" > < / script > < title > auth | arthas< / title > < meta name = "description" content = "arthas 使用文档" >
< link rel = "modulepreload" href = "/assets/app.170c6bb7.js" > < link rel = "modulepreload" href = "/assets/auth.html.ed450cf2.js" > < link rel = "modulepreload" href = "/assets/auth.html.976ea268.js" > < link rel = "prefetch" href = "/assets/index.html.027a535c.js" > < link rel = "prefetch" href = "/assets/index.html.f4fc56b4.js" > < link rel = "prefetch" href = "/assets/index.html.4fabef9a.js" > < link rel = "prefetch" href = "/assets/advanced-use.html.a364a077.js" > < link rel = "prefetch" href = "/assets/advice-class.html.1e16b78a.js" > < link rel = "prefetch" href = "/assets/agent.html.ea4b4c17.js" > < link rel = "prefetch" href = "/assets/arthas-properties.html.3c6dd837.js" > < link rel = "prefetch" href = "/assets/arthas3.html.653e03bd.js" > < link rel = "prefetch" href = "/assets/async.html.c7f2ec88.js" > < link rel = "prefetch" href = "/assets/base64.html.0ce179d7.js" > < link rel = "prefetch" href = "/assets/batch-support.html.a8ea483a.js" > < link rel = "prefetch" href = "/assets/cat.html.57193482.js" > < link rel = "prefetch" href = "/assets/classloader.html.1cccb103.js" > < link rel = "prefetch" href = "/assets/cls.html.9cc716a2.js" > < link rel = "prefetch" href = "/assets/commands.html.9b04eeb3.js" > < link rel = "prefetch" href = "/assets/contact-us.html.4b75bb12.js" > < link rel = "prefetch" href = "/assets/dashboard.html.471cdbf0.js" > < link rel = "prefetch" href = "/assets/docker.html.eef4a9b6.js" > < link rel = "prefetch" href = "/assets/download.html.ff354b6f.js" > < link rel = "prefetch" href = "/assets/dump.html.c72d4940.js" > < link rel = "prefetch" href = "/assets/echo.html.49af5ef2.js" > < link rel = "prefetch" href = "/assets/faq.html.75378aba.js" > < link rel = "prefetch" href = "/assets/getstatic.html.dafe19bf.js" > < link rel = "prefetch" href = "/assets/grep.html.1d94643c.js" > < link rel = "prefetch" href = "/assets/groovy.html.982837a9.js" > < link rel = "prefetch" href = "/assets/heapdump.html.770781d7.js" > < link rel = "prefetch" href = "/assets/help.html.509b4db6.js" > < link rel = "prefetch" href = "/assets/history.html.24c98bc1.js" > < link rel = "prefetch" href = "/assets/http-api.html.c0834238.js" > < link rel = "prefetch" href = "/assets/idea-plugin.html.ec624e96.js" > < link rel = "prefetch" href = "/assets/install-detail.html.76d1df70.js" > < link rel = "prefetch" href = "/assets/jad.html.f02068c8.js" > < link rel = "prefetch" href = "/assets/jfr.html.0b62ef92.js" > < link rel = "prefetch" href = "/assets/jvm.html.9b6cb899.js" > < link rel = "prefetch" href = "/assets/keymap.html.a8e445a7.js" > < link rel = "prefetch" href = "/assets/logger.html.635d0790.js" > < link rel = "prefetch" href = "/assets/manual-install.html.c49561b2.js" > < link rel = "prefetch" href = "/assets/mbean.html.c09c879d.js" > < link rel = "prefetch" href = "/assets/mc.html.d9028bda.js" > < link rel = "prefetch" href = "/assets/memory.html.953a0d4f.js" > < link rel = "prefetch" href = "/assets/monitor.html.7df88e93.js" > < link rel = "prefetch" href = "/assets/ognl.html.aa12b486.js" > < link rel = "prefetch" href = "/assets/options.html.0348e01c.js" > < link rel = "prefetch" href = "/assets/perfcounter.html.098c9c9e.js" > < link rel = "prefetch" href = "/assets/profiler.html.8be69b54.js" > < link rel = "prefetch" href = "/assets/pwd.html.713f9c32.js" > < link rel = "prefetch" href = "/assets/quick-start.html.be359054.js" > < link rel = "prefetch" href = "/assets/quit.html.02ca41a5.js" > < link rel = "prefetch" href = "/assets/redefine.html.5a9b270a.js" > < link rel = "prefetch" href = "/assets/release-notes.html.a57b43af.js" > < link rel = "prefetch" href = "/assets/reset.html.9c4606b8.js" > < link rel = "prefetch" href = "/assets/retransform.html.6e43ccc9.js" > < link rel = "prefetch" href = "/assets/save-log.html.8bdd55ac.js" > < link rel = "prefetch" href = "/assets/sc.html.a90007ab.js" > < link rel = "prefetch" href = "/assets/session.html.e6db1dfb.js" > < link rel = "prefetch" href = "/assets/sm.html.24ba31c4.js" > < link rel = "prefetch" href = "/assets/spring-boot-starter.html.b19d8a00.js" > < link rel = "prefetch" href = "/assets/stack.html.466606a8.js" > < link rel = "prefetch" href = "/assets/start-arthas.html.b89051d7.js" > < link rel = "prefetch" href = "/assets/stop.html.31f63c78.js" > < link rel = "prefetch" href = "/assets/sysenv.html.bac684ed.js" > < link rel = "prefetch" href = "/assets/sysprop.html.85801cda.js" > < link rel = "prefetch" href = "/assets/tee.html.2888ae13.js" > < link rel = "prefetch" href = "/assets/thread.html.712d553e.js"
< link rel = "stylesheet" href = "/assets/style.da1934a3.css" >
< / head >
< body >
< div id = "app" > <!-- [ --> < div class = "theme-container" > <!-- [ --> < header class = "navbar" > < div class = "toggle-sidebar-button" title = "切换侧边栏" aria-expanded = "false" role = "button" tabindex = "0" > < div class = "icon" aria-hidden = "true" > < span > < / span > < span > < / span > < span > < / span > < / div > < / div > < span > < a href = "/" class = "" data-v-61144abc > <!-- --> < span class = "site-name can-hide" data-v-61144abc > arthas< / span > < span class = "navbar-version" data-v-61144abc > v3.7.0< / span > < / a > < / span > < div class = "navbar-items-wrapper" style = "" > <!-- [ --> <!-- ] --> < nav class = "navbar-items can-hide" > <!-- [ --> < div class = "navbar-item" > < a href = "/" class = "" aria-label = "首页" > <!-- [ --> <!-- ] --> 首页 <!-- [ --> <!-- ] --> < / a > < / div > < div class = "navbar-item" > < a class = "external-link" href = "/doc/arthas-tutorials.html?language=cn&id=arthas-basics" rel = "noopener noreferrer" target = "_blank" aria-label = "在线教程" > <!-- [ --> <!-- ] --> < span > 在线教程< / span > < span > < svg class = "external-link-icon" xmlns = "http://www.w3.org/2000/svg" aria-hidden = "true" focusable = "false" x = "0px" y = "0px" viewbox = "0 0 100 100" width = "15" height = "15" > < path fill = "currentColor" d = "M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z" > < / path > < polygon fill = "currentColor" points = "45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9" > < / polygon > < / svg > < span class = "external-link-icon-sr-only" > 在新窗口打开< / span > < / span > <!-- [ --> <!-- ] --> < / a > < / div > < div class = "navbar-item" > < a href = "/doc/" class = "router-link-active" aria-label = "文档" > <!-- [ --> <!-- ] --> 文档 <!-- [ --> <!-- ] --> < / a > < / div > < div class = "navbar-item" > < a href = "/doc/commands.md" class = "" aria-label = "命令列表" > <!-- [ --> <!-- ] --> 命令列表 <!-- [ --> <!-- ] --> < / a > < / div > < div class = "navbar-item" > < a href = "/doc/download.md" class = "" aria-label = "下载" > <!-- [ --> <!-- ] --> 下载 <!-- [ --> <!-- ] --> < / a > < / div > < div class = "navbar-item" > < div class = "navbar-dropdown-wrapper" > < button class = "navbar-dropdown-title" type = "button" aria-label = "解决方案" > < span class = "title" > 解决方案< / span > < span class = "arrow down" > < / span > < / button > < button class = "navbar-dropdown-title-mobile" type = "button" aria-label = "解决方案" > < span class = "title" > 解决方案< / span > < span class = "right arrow" > < / span > < / button > < ul style = "display:none;" class = "navbar-dropdown" > <!-- [ --> < li class = "navbar-dropdown-item" > < a class = "external-link" href = "https://cn.aliyun.com/product/aliware/mse?spm=arthas.topbar.0.0.0" rel = "noopener noreferrer" target = "_blank" aria-label = "微服务解决方案" > <!-- [ --> <!-- ] --> < span > 微服务解决方案< / span > < span > < svg class = "external-link-icon" xmlns = "http://www.w3.org/2000/svg" aria-hidden = "true" focusable = "false" x = "0px" y = "0px" viewbox = "0 0 100 100" width = "15" height = "15" > < path fill = "currentColor" d = "M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z" > < / path > < polygon fill = "currentColor" points = "45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9" > < / polygon > < / svg > < span class = "external-link-icon-sr-only" > 在新窗口打开< / span > < / span > <!-- [ --> <!-- ] --> < / a > < / li > < li class = "navbar-dropdown-item" > < a class = "external-link" href = "https://www.aliyun.com/aliware/txc?spm=arthas.topbar.0.0.0" rel = "noopener noreferrer" target = "_blank" aria-label = "分布式事务解决方案" > <!-- [ --> <!-- ] --> < span > 分布式事务解决方案< / span > < span > < svg class = "external-link-icon" xmlns = "http://www.w3.org/2000/svg" aria-hidden = "true" focusable = "false" x = "0px" y = "0px" viewbox = "0 0 100 100" width = "15" height = "15" > < path fill = "currentColor" d = "M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z" > < / path > < polygon fill = "currentColor" points = "45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9" > < / polygon > < / svg > < span class = "external-link-icon-sr-only" > 在新窗口打开< / span > < / span > <!-- [ --> <!-- ] --> < / a > < / li > < li class = "navbar-dropdown-item" > < a class = "external-link" href = "https://www.aliyun.com/product/ahas?spm=artha
< / code > < / pre > < div class = "line-numbers" aria-hidden = "true" > < div class = "line-number" > < / div > < / div > < / div > < ul > < li > < p > 可以通过 < code > --username< / code > 选项来指定用户,默认值是< code > arthas< / code > 。< / p > < / li > < li > < p > 也可以在 < code > arthas.properties< / code > 里中配置 username/password。命令行的优先级大于配置文件。< / p > < / li > < li > < p > 如果只配置< code > username< / code > ,没有配置< code > password< / code > ,则会生成随机密码,打印在< code > ~/logs/arthas/arthas.log< / code > 中< / p > < div class = "language-text ext-text line-numbers-mode" > < pre class = "language-text" > < code > Using generated security password: 0vUBJpRIppkKuZ7dYzYqOKtranj4unGh
< / code > < / pre > < div class = "line-numbers" aria-hidden = "true" > < div class = "line-number" > < / div > < / div > < / div > < / li > < / ul > < h2 id = "本地连接不鉴权" tabindex = "-1" > < a class = "header-anchor" href = "#本地连接不鉴权" aria-hidden = "true" > #< / a > 本地连接不鉴权< / h2 > < p > 默认情况下,在< code > arthas.properties< / code > 文件里有配置:< / p > < div class = "language-text ext-text line-numbers-mode" > < pre class = "language-text" > < code > arthas.localConnectionNonAuth=true
< / code > < / pre > < div class = "line-numbers" aria-hidden = "true" > < div class = "line-number" > < / div > < / div > < / div > < p > 当配置密码时,使用本地连接,也不需要鉴权。默认配置值是 true, 方便本地连接使用。只有远程连接时, 才需要鉴权。< / p > < h2 id = "在-telnet-console-里鉴权" tabindex = "-1" > < a class = "header-anchor" href = "#在-telnet-console-里鉴权" aria-hidden = "true" > #< / a > 在 telnet console 里鉴权< / h2 > < p > 连接到 arthas 后,直接执行命令会提示需要鉴权:< / p > < div class = "language-bash ext-sh line-numbers-mode" > < pre class = "language-bash" > < code > < span class = "token punctuation" > [< / span > arthas@37430< span class = "token punctuation" > ]< / span > $ < span class = "token builtin class-name" > help< / span >
Error< span class = "token operator" > !< / span > < span class = "token builtin class-name" > command< / span > not permitted, try to use < span class = "token string" > ' auth' < / span > < span class = "token builtin class-name" > command< / span > to authenticates.
< / code > < / pre > < div class = "line-numbers" aria-hidden = "true" > < div class = "line-number" > < / div > < div class = "line-number" > < / div > < / div > < / div > < p > 使用< code > auth< / code > 命令来鉴权,成功之后可以执行其它命令。< / p > < div class = "language-text ext-text line-numbers-mode" > < pre class = "language-text" > < code > [arthas@37430]$ auth ppp
Authentication result: true
< / code > < / pre > < div class = "line-numbers" aria-hidden = "true" > < div class = "line-number" > < / div > < div class = "line-number" > < / div > < / div > < / div > < ul > < li > 可以通过 < code > --username< / code > 选项来指定用户,默认值是< code > arthas< / code > 。< / li > < / ul > < h2 id = "web-console-密码验证" tabindex = "-1" > < a class = "header-anchor" href = "#web-console-密码验证" aria-hidden = "true" > #< / a > Web console 密码验证< / h2 > < p > 打开浏览器,会有弹窗提示需要输入 用户名 和 密码。< / p > < p > 成功之后,则可以直接连接上 web console。< / p > < h2 id = "http-api-验证" tabindex = "-1" > < a class = "header-anchor" href = "#http-api-验证" aria-hidden = "true" > #< / a > HTTP API 验证< / h2 > < h3 id = "authorization-header-方式-推荐" tabindex = "-1" > < a class = "header-anchor" href = "#authorization-header-方式-推荐" aria-hidden = "true" > #< / a > Authorization Header 方式(推荐)< / h3 > < p > Arthas 采用的是 HTTP 标准的 Basic Authorization, 客户端请求时增加对应的 header 即可。< / p > < ul > < li > 参考:< a href = "https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication" target = "_blank" rel = "noopener noreferrer" > https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication< span > < svg class = "external-link-icon" xmlns = "http://www.w3.org/2000/svg" aria-hidden = "true" focusable = "false" x = "0px" y = "0px" viewbox = "0 0 100 100" width = "15" height = "15" > < path fill = "currentColor" d = "M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z" > < / path > < polygon fill = "currentColor" points = "45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9" > < / polygon > < / svg > < span class = "external-link-icon-sr-only" > 在新窗口打开< / span > < / span > < / a > < / li > < / ul > < p > 例如,用户名是:< code > admin< / code > ,密码是 < code > admin< / code > ,则组合为字符串: < code > admin:admin< / code > , base64 结果是: < code > YWRtaW46YWRtaW4=< / code > ,则 HTTP 请求增加< code > Authorization< / code > header: < / p > < div class = "language-bash ext-sh line-numbers-mode" > < pre class = "language-bash" > < code > < span class = "token function" > curl< / span > < span class = "token string" > ' http://localhost:8563/api' < / span > < span class = "token punctuation" > \< / span >
< span class = "token parameter variable" > -H< / span > < span class = "token string" > ' Authorization: Basic YWRtaW46YWRtaW4=' < / span > < span class = "token punctuation" > \< / span >
--data-raw < span class = "token string" > ' {" action" :" exec" ," command" :" version" }' < / span >
< / code > < / pre > < div class = "line-numbers" aria-hidden = "true" > < div class = "line-number" > < / div > < div class = "line-number" > < / div > < div class = "line-number" > < / div > < / div > < / div > < h3 id = "url-参数传递方式" tabindex = "-1" > < a class = "header-anchor" href = "#url-参数传递方式" aria-hidden = "true" > #< / a > URL 参数传递方式< / h3 > < p > 为了方便各种特殊情况,支持了以 parameters 方式传递 username 和 password。比如: < / p > < div class = "language-bash ext-sh line-numbers-mode" > < pre class = "language-bash" > < code > < span class = "token function" > curl< / span > < span class = "token string" > ' http://localhost:8563/api?password=admin' < / span > < span class = "token punctuation" > \< / span >
--data-raw < span class = "token string" > ' {" action" :" exec" ," command" :" version" }' < / span >
< / code > < / pre > < div class = "line-numbers" aria-hidden = "true" > < div class = "line-number" > < / div > < div class = "line-number" > < / div > < / div > < / div > < / div > <!-- [ --> <!-- ] --> < / div > < footer class = "page-meta right-menu-padding" data-v-fdd717e0 > < div class = "meta-item edit-link" > < a class = "external-link meta-item-label" href = "https://github.com/alibaba/arthas/edit/master/site/docs/doc/auth.md" rel = "noopener noreferrer" target = "_blank" aria-label = "在 GitHub 上编辑此页" > <!-- [ --> <!-- ] --> < span > 在 GitHub 上编辑此页< / span > < span > < svg class = "external-link-icon" xmlns = "http://www.w3.org/2000/svg" aria-hidden = "true" focusable = "false" x = "0px" y = "0px" viewbox = "0 0 100 100" width = "15" height = "15" > < path fill = "currentColor" d = "M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z" > < / path > < polygon fill = "currentColor" points = "45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9" > < / polygon > < / svg > < span class = "external-link-icon-sr-only" > 在新窗口打开< / span > < / span > <!-- [ --> <!-- ] --> < / a > < / div > < div class = "meta-item last-updated" > < span class = "meta-item-label" > Last Updated: < / span > <!-- --> < / div > < div class = "meta-item contributors" > < span class = "meta-item-label" > 贡献者: < / span > < span class = "meta-item-info" > <!-- [ --> <!-- [ --> < span class = "contributor" title = "email: hengyunabc@gmail.com" > hengyunabc< / span > <!-- [ --> , <!-- ] --> <!-- ] --> <!-- [ --> < span class = "contributor" title = "email: i@fatpandac.com" > Fatpandac< / span > <!-- --> <!-- ] --> <!-- ] --> < / span > < / div > < / footer > < nav class = "page-nav right-menu-padding" data-v-fdd717e0 > < p class = "inner" > < span class = "prev" > < a href = "/doc/jfr.html" class = "" aria-label = "jfr" > <!-- [ --> <!-- ] --> jfr <!-- [ --> <!-- ] --> < / a > < / span > < span class = "next" > < a href = "/doc/options.html" class = "" aria-label = "options" > <!-- [ --> <!-- ] --> options <!-- [ --> <!-- ] --> < / a > < / span > < / p > < / nav > <!-- [ --> <!-- ] --> < / main > <!-- ] --> < / div > <!-- --> <!-- ] --> < / div >
< script type = "module" src = "/assets/app.170c6bb7.js" defer > < / script >
< / body >
< / html >