-ji-lu--shi-yong-Termux-zuo-wei-SSH-ke-hu-duan.html 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. <!DOCTYPE html>
  2. <html lang="en" data-default-color-scheme=auto>
  3. <head><!-- hexo injector head_begin start -->
  4. <script defer src="https://api.limour.top/vue/0d2f95c1-755d-436b-adf8-eee12a80ed32/script.js"></script>
  5. <!-- hexo injector head_begin end -->
  6. <meta charset="UTF-8">
  7. <link rel="apple-touch-icon" sizes="76x76" href="https://img.limour.top/2023/08/29/64ee07361815a.webp">
  8. <link rel="icon" href="https://img.limour.top/2023/08/29/64ee07361815a.webp">
  9. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  10. <meta http-equiv="x-ua-compatible" content="ie=edge">
  11. <meta name="theme-color" content="#2f4154">
  12. <meta name="author" content="Limour">
  13. <meta name="keywords" content="">
  14. <meta name="description" content="这段文字是关于在Termux上安装和配置Alpine Linux以及使用SSH登录的指南。首先需要下载并安装Termux应用,然后通过命令行安装proot-distro并使用它来安装Alpine Linux。接下来需要修改Alpine Linux的软件源为清华大学镜像并更新软件包并安装openssh。然后可以通过编辑SSH配置文件并生成SSH密钥来设置快捷登录。最后,可以使用SSH命令直接登录到指">
  15. <title>【记录】使用 Termux 作为 SSH 客户端 - Limour&#39;s Blog</title>
  16. <link rel="stylesheet" href="https://jscdn.limour.top/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css" />
  17. <link rel="stylesheet" href="https://jscdn.limour.top/npm/github-markdown-css@4.0.0/github-markdown.min.css" />
  18. <link rel="stylesheet" href="https://jscdn.limour.top/npm/hint.css@2.7.0/hint.min.css" />
  19. <!-- 主题依赖的图标库,不要自行修改 -->
  20. <!-- Do not modify the link that theme dependent icons -->
  21. <link rel="stylesheet" href="//at.alicdn.com/t/c/font_1749284_5i9bdhy70f8.css">
  22. <link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">
  23. <link rel="stylesheet" href="/css/main.css" />
  24. <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  25. <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  26. <link rel="stylesheet" href="/theme-inject/custom.css">
  27. <link rel="stylesheet" href="/theme-inject/iconfont.css">
  28. <script id="fluid-configs">
  29. var Fluid = window.Fluid || {};
  30. Fluid.ctx = Object.assign({}, Fluid.ctx)
  31. var CONFIG = {"hostname":"hexo.limour.top","root":"/","version":"1.9.8","typing":{"enable":false,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":"§"},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":false,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":{"measurement_id":null},"tencent":{"sid":null,"cid":null},"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false},"umami":{"src":null,"website_id":null,"domains":null,"start_time":"2024-01-01T00:00:00.000Z","token":null,"api_server":null},"woyaola":null,"cnzz":null},"search_path":"/local-search.xml","include_content_in_search":true};
  32. if (CONFIG.web_analytics.follow_dnt) {
  33. var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
  34. Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
  35. }
  36. </script>
  37. <script src="/js/utils.js" ></script>
  38. <script src="/js/color-schema.js" ></script>
  39. <link rel="canonical" href="https://hexo.limour.top/-ji-lu--shi-yong-Termux-zuo-wei-SSH-ke-hu-duan"/>
  40. <meta name="generator" content="Hexo 7.1.1"><link rel="alternate" href="/atom.xml" title="Limour's Blog" type="application/atom+xml">
  41. <link rel="alternate" href="/rss2.xml" title="Limour's Blog" type="application/rss+xml">
  42. </head>
  43. <body>
  44. <header>
  45. <div class="header-inner" style="height: 70vh;">
  46. <nav id="navbar" class="navbar fixed-top navbar-expand-lg navbar-dark scrolling-navbar">
  47. <div class="container">
  48. <a class="navbar-brand" href="/">
  49. <strong>Limour&#39;s Blog</strong>
  50. </a>
  51. <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
  52. data-target="#navbarSupportedContent"
  53. aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  54. <div class="animated-icon"><span></span><span></span><span></span></div>
  55. </button>
  56. <!-- Collapsible content -->
  57. <div class="collapse navbar-collapse" id="navbarSupportedContent">
  58. <ul class="navbar-nav ml-auto text-center">
  59. <li class="nav-item">
  60. <a class="nav-link" href="https://hexo.limour.top/" target="_self">
  61. <i class="iconfont icon-home-fill"></i>
  62. <span>Home</span>
  63. </a>
  64. </li>
  65. <li class="nav-item">
  66. <a class="nav-link" href="/archives/" target="_self">
  67. <i class="iconfont icon-archive-fill"></i>
  68. <span>Archive1</span>
  69. </a>
  70. </li>
  71. <li class="nav-item">
  72. <a class="nav-link" href="https://occdn.limour.top/archives/" target="_self">
  73. <i class="iconfont icon-archive-fill"></i>
  74. <span>Archive2</span>
  75. </a>
  76. </li>
  77. <li class="nav-item">
  78. <a class="nav-link" href="https://b.limour.top/archives/" target="_self">
  79. <i class="iconfont icon-archive-fill"></i>
  80. <span>Archive3</span>
  81. </a>
  82. </li>
  83. <li class="nav-item">
  84. <a class="nav-link" href="https://od.limour.top/" target="_self">
  85. <i class="iconfont icon-onedrive"></i>
  86. <span>Alist</span>
  87. </a>
  88. </li>
  89. <li class="nav-item">
  90. <a class="nav-link" href="https://orcid.org/0000-0001-8897-1685" target="_self">
  91. <i class="iconfont icon-orcid"></i>
  92. <span>Orcid</span>
  93. </a>
  94. </li>
  95. <li class="nav-item">
  96. <a class="nav-link" href="/links/" target="_self">
  97. <i class="iconfont icon-link-fill"></i>
  98. <span>Links</span>
  99. </a>
  100. </li>
  101. <li class="nav-item">
  102. <a class="nav-link" href="/atom.xml" target="_self">
  103. <i class="iconfont icon-rss"></i>
  104. <span>RSS</span>
  105. </a>
  106. </li>
  107. <li class="nav-item" id="search-btn">
  108. <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
  109. <i class="iconfont icon-search"></i>
  110. </a>
  111. </li>
  112. <li class="nav-item" id="color-toggle-btn">
  113. <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
  114. <i class="iconfont icon-dark" id="color-toggle-icon"></i>
  115. </a>
  116. </li>
  117. </ul>
  118. </div>
  119. </div>
  120. </nav>
  121. <div id="banner" class="banner" parallax=true
  122. style="background: url('https://img.limour.top/2023/08/29/64ee08e108638.webp') no-repeat center center; background-size: cover;">
  123. <div class="full-bg-img">
  124. <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
  125. <div class="banner-text text-center fade-in-up">
  126. <div class="h2">
  127. <span id="subtitle">【记录】使用 Termux 作为 SSH 客户端</span>
  128. </div>
  129. <div class="mt-3">
  130. <span class="post-meta mr-2">
  131. <i class="iconfont icon-author" aria-hidden="true"></i>
  132. Limour
  133. </span>
  134. <span class="post-meta">
  135. <i class="iconfont icon-date-fill" aria-hidden="true"></i>
  136. <time datetime="2023-07-22 20:19" pubdate>
  137. July 22, 2023 pm
  138. </time>
  139. </span>
  140. </div>
  141. <div class="mt-1">
  142. <span class="post-meta mr-2">
  143. <i class="iconfont icon-chart"></i>
  144. 1.4k words
  145. </span>
  146. <span class="post-meta mr-2">
  147. <i class="iconfont icon-clock-fill"></i>
  148. 12 mins
  149. </span>
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. </header>
  157. <main>
  158. <div class="container-fluid nopadding-x">
  159. <div class="row nomargin-x">
  160. <div class="side-col d-none d-lg-block col-lg-2">
  161. </div>
  162. <div class="col-lg-8 nopadding-x-md">
  163. <div class="container nopadding-x-md" id="board-ctn">
  164. <div id="board">
  165. <article class="post-content mx-auto">
  166. <h1 id="seo-header">【记录】使用 Termux 作为 SSH 客户端</h1>
  167. <p id="updated-time" class="note note-info" style="">
  168. Last updated on March 19, 2024 pm
  169. </p>
  170. <div class="markdown-body">
  171. <h2 id="安装-Termux">安装 Termux</h2>
  172. <ul>
  173. <li>下载 <a href="https://hexo.limour.top/go/#aHR0cHM6Ly9naXRodWIuY29tL3Rlcm11eC90ZXJtdXgtYXBw" rel="noopener external nofollow noreferrer">termux-app</a>(<a href="https://hexo.limour.top/go/#aHR0cHM6Ly9naXRodWIuY29tL3p3YzQ1NmJhYnkvZmlsZS1wcm94eQ==" rel="noopener external nofollow noreferrer">点此镜像加速</a>)</li>
  174. </ul>
  175. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs bash">pkg install proot-distro<br>proot-distro install alpine<br>proot-distro login alpine<br>sed -i <span class="hljs-string">&#x27;s/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g&#x27;</span> /etc/apk/repositories<br>apk update &amp;&amp; apk add openssh<br></code></pre></td></tr></table></figure>
  176. <h2 id="快捷登录">快捷登录</h2>
  177. <figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs ini">host SER5<br> user root<br> hostname limour.top<br> Port 22<br> <span class="hljs-comment"># PreferredAuthentications publickey</span><br> <span class="hljs-comment"># IdentityFile ~/.ssh/id_rsa</span><br></code></pre></td></tr></table></figure>
  178. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs bash">nano ~/.ssh/config <span class="hljs-comment"># 写入上面的配置文件</span><br>ssh-keygen -t rsa<br>ssh-copy-id SER5<br>nano ~/.ssh/config <span class="hljs-comment"># 将注释取消掉</span><br>ssh SER5 <span class="hljs-comment"># 即可直接登录</span><br></code></pre></td></tr></table></figure>
  179. <h2 id="附加-简易上传服务">附加 简易上传服务</h2>
  180. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">python upload.py 8000<br></code></pre></td></tr></table></figure>
  181. <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-comment">#!/usr/bin/env python</span><br><span class="hljs-comment"># -*- coding: UTF-8 -*-</span><br><br><span class="hljs-string">&quot;&quot;&quot;Simple HTTP Server With Upload.</span><br><span class="hljs-string">This module builds on BaseHTTPServer by implementing the standard GET</span><br><span class="hljs-string">and HEAD requests in a fairly straightforward manner.</span><br><span class="hljs-string">&quot;&quot;&quot;</span><br><br>__version__ = <span class="hljs-string">&quot;0.3.1&quot;</span><br>__author__ = <span class="hljs-string">&quot;freelamb@126.com&quot;</span><br>__all__ = [<span class="hljs-string">&quot;SimpleHTTPRequestHandler&quot;</span>]<br><br><span class="hljs-keyword">import</span> os<br><span class="hljs-keyword">import</span> sys<br><span class="hljs-keyword">import</span> argparse<br><span class="hljs-keyword">import</span> posixpath<br><span class="hljs-keyword">try</span>:<br> <span class="hljs-keyword">from</span> html <span class="hljs-keyword">import</span> escape<br><span class="hljs-keyword">except</span> ImportError:<br> <span class="hljs-keyword">from</span> cgi <span class="hljs-keyword">import</span> escape<br><span class="hljs-keyword">import</span> shutil<br><span class="hljs-keyword">import</span> mimetypes<br><span class="hljs-keyword">import</span> re<br><span class="hljs-keyword">import</span> signal<br><span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> StringIO, BytesIO<br><br><span class="hljs-keyword">if</span> sys.version_info.major == <span class="hljs-number">3</span>:<br> <span class="hljs-comment"># Python3</span><br> <span class="hljs-keyword">from</span> urllib.parse <span class="hljs-keyword">import</span> quote<br> <span class="hljs-keyword">from</span> urllib.parse <span class="hljs-keyword">import</span> unquote<br> <span class="hljs-keyword">from</span> http.server <span class="hljs-keyword">import</span> HTTPServer<br> <span class="hljs-keyword">from</span> http.server <span class="hljs-keyword">import</span> BaseHTTPRequestHandler<br><span class="hljs-keyword">else</span>:<br> <span class="hljs-comment"># Python2</span><br> reload(sys)<br> sys.setdefaultencoding(<span class="hljs-string">&#x27;utf-8&#x27;</span>)<br> <span class="hljs-keyword">from</span> urllib <span class="hljs-keyword">import</span> quote<br> <span class="hljs-keyword">from</span> urllib <span class="hljs-keyword">import</span> unquote<br> <span class="hljs-keyword">from</span> BaseHTTPServer <span class="hljs-keyword">import</span> HTTPServer<br> <span class="hljs-keyword">from</span> BaseHTTPServer <span class="hljs-keyword">import</span> BaseHTTPRequestHandler<br><br><br><span class="hljs-keyword">class</span> <span class="hljs-title class_">SimpleHTTPRequestHandler</span>(<span class="hljs-title class_ inherited__">BaseHTTPRequestHandler</span>):<br> <span class="hljs-string">&quot;&quot;&quot;Simple HTTP request handler with GET/HEAD/POST commands.</span><br><span class="hljs-string"> This serves files from the current directory and any of its</span><br><span class="hljs-string"> subdirectories. The MIME type for files is determined by</span><br><span class="hljs-string"> calling the .guess_type() method. And can receive file uploaded</span><br><span class="hljs-string"> by client.</span><br><span class="hljs-string"> The GET/HEAD/POST requests are identical except that the HEAD</span><br><span class="hljs-string"> request omits the actual contents of the file.</span><br><span class="hljs-string"> &quot;&quot;&quot;</span><br><br> server_version = <span class="hljs-string">&quot;simple_http_server/&quot;</span> + __version__<br><br> <span class="hljs-keyword">def</span> <span class="hljs-title function_">do_GET</span>(<span class="hljs-params">self</span>):<br> <span class="hljs-string">&quot;&quot;&quot;Serve a GET request.&quot;&quot;&quot;</span><br> fd = self.send_head()<br> <span class="hljs-keyword">if</span> fd:<br> shutil.copyfileobj(fd, self.wfile)<br> fd.close()<br><br> <span class="hljs-keyword">def</span> <span class="hljs-title function_">do_HEAD</span>(<span class="hljs-params">self</span>):<br> <span class="hljs-string">&quot;&quot;&quot;Serve a HEAD request.&quot;&quot;&quot;</span><br> fd = self.send_head()<br> <span class="hljs-keyword">if</span> fd:<br> fd.close()<br><br> <span class="hljs-keyword">def</span> <span class="hljs-title function_">do_POST</span>(<span class="hljs-params">self</span>):<br> <span class="hljs-string">&quot;&quot;&quot;Serve a POST request.&quot;&quot;&quot;</span><br> r, info = self.deal_post_data()<br> <span class="hljs-built_in">print</span>(r, info, <span class="hljs-string">&quot;by: &quot;</span>, self.client_address)<br> f = BytesIO()<br> f.write(<span class="hljs-string">b&#x27;&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 3.2 Final//EN&quot;&gt;&#x27;</span>)<br> f.write(<span class="hljs-string">b&quot;&lt;html&gt;\n&lt;title&gt;Upload Result Page&lt;/title&gt;\n&quot;</span>)<br> f.write(<span class="hljs-string">b&quot;&lt;body&gt;\n&lt;h2&gt;Upload Result Page&lt;/h2&gt;\n&quot;</span>)<br> f.write(<span class="hljs-string">b&quot;&lt;hr&gt;\n&quot;</span>)<br> <span class="hljs-keyword">if</span> r:<br> f.write(<span class="hljs-string">b&quot;&lt;strong&gt;Success:&lt;/strong&gt;&quot;</span>)<br> <span class="hljs-keyword">else</span>:<br> f.write(<span class="hljs-string">b&quot;&lt;strong&gt;Failed:&lt;/strong&gt;&quot;</span>)<br> f.write(info.encode(<span class="hljs-string">&#x27;utf-8&#x27;</span>))<br> f.write(<span class="hljs-string">b&quot;&lt;br&gt;&lt;a href=\&quot;.\&quot;&gt;back&lt;/a&gt;&quot;</span>)<br> f.write(<span class="hljs-string">b&quot;&lt;hr&gt;&lt;small&gt;Powered By: freelamb, check new version at &quot;</span>)<br> f.write(<span class="hljs-string">b&quot;&lt;a href=\&quot;https://github.com/freelamb/simple_http_server\&quot;&gt;&quot;</span>)<br> f.write(<span class="hljs-string">b&quot;here&lt;/a&gt;.&lt;/small&gt;&lt;/body&gt;\n&lt;/html&gt;\n&quot;</span>)<br> length = f.tell()<br> f.seek(<span class="hljs-number">0</span>)<br> self.send_response(<span class="hljs-number">200</span>)<br> self.send_header(<span class="hljs-string">&quot;Content-type&quot;</span>, <span class="hljs-string">&quot;text/html;charset=utf-8&quot;</span>)<br> self.send_header(<span class="hljs-string">&quot;Content-Length&quot;</span>, <span class="hljs-built_in">str</span>(length))<br> self.end_headers()<br> <span class="hljs-keyword">if</span> f:<br> shutil.copyfileobj(f, self.wfile)<br> f.close()<br><br> <span class="hljs-keyword">def</span> <span class="hljs-title function_">deal_post_data</span>(<span class="hljs-params">self</span>):<br> boundary = self.headers[<span class="hljs-string">&quot;Content-Type&quot;</span>].split(<span class="hljs-string">&quot;=&quot;</span>)[<span class="hljs-number">1</span>].encode(<span class="hljs-string">&#x27;utf-8&#x27;</span>)<br> remain_bytes = <span class="hljs-built_in">int</span>(self.headers[<span class="hljs-string">&#x27;content-length&#x27;</span>])<br> line = self.rfile.readline()<br> remain_bytes -= <span class="hljs-built_in">len</span>(line)<br> <span class="hljs-keyword">if</span> boundary <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> line:<br> <span class="hljs-keyword">return</span> <span class="hljs-literal">False</span>, <span class="hljs-string">&quot;Content NOT begin with boundary&quot;</span><br> line = self.rfile.readline()<br> remain_bytes -= <span class="hljs-built_in">len</span>(line)<br> fn = re.findall(<span class="hljs-string">r&#x27;Content-Disposition.*name=&quot;file&quot;; filename=&quot;(.*)&quot;&#x27;</span>, line.decode(<span class="hljs-string">&#x27;utf-8&#x27;</span>))<br> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> fn:<br> <span class="hljs-keyword">return</span> <span class="hljs-literal">False</span>, <span class="hljs-string">&quot;Can&#x27;t find out file name...&quot;</span><br> path = translate_path(self.path)<br> fn = os.path.join(path, fn[<span class="hljs-number">0</span>])<br> <span class="hljs-keyword">while</span> os.path.exists(fn):<br> fn += <span class="hljs-string">&quot;_&quot;</span><br> line = self.rfile.readline()<br> remain_bytes -= <span class="hljs-built_in">len</span>(line)<br> line = self.rfile.readline()<br> remain_bytes -= <span class="hljs-built_in">len</span>(line)<br> <span class="hljs-keyword">try</span>:<br> out = <span class="hljs-built_in">open</span>(fn, <span class="hljs-string">&#x27;wb&#x27;</span>)<br> <span class="hljs-keyword">except</span> IOError:<br> <span class="hljs-keyword">return</span> <span class="hljs-literal">False</span>, <span class="hljs-string">&quot;Can&#x27;t create file to write, do you have permission to write?&quot;</span><br><br> pre_line = self.rfile.readline()<br> remain_bytes -= <span class="hljs-built_in">len</span>(pre_line)<br> <span class="hljs-keyword">while</span> remain_bytes &gt; <span class="hljs-number">0</span>:<br> line = self.rfile.readline()<br> remain_bytes -= <span class="hljs-built_in">len</span>(line)<br> <span class="hljs-keyword">if</span> boundary <span class="hljs-keyword">in</span> line:<br> pre_line = pre_line[<span class="hljs-number">0</span>:-<span class="hljs-number">1</span>]<br> <span class="hljs-keyword">if</span> pre_line.endswith(<span class="hljs-string">b&#x27;\r&#x27;</span>):<br> pre_line = pre_line[<span class="hljs-number">0</span>:-<span class="hljs-number">1</span>]<br> out.write(pre_line)<br> out.close()<br> <span class="hljs-keyword">return</span> <span class="hljs-literal">True</span>, <span class="hljs-string">&quot;File &#x27;%s&#x27; upload success!&quot;</span> % fn<br> <span class="hljs-keyword">else</span>:<br> out.write(pre_line)<br> pre_line = line<br> <span class="hljs-keyword">return</span> <span class="hljs-literal">False</span>, <span class="hljs-string">&quot;Unexpect Ends of data.&quot;</span><br><br> <span class="hljs-keyword">def</span> <span class="hljs-title function_">send_head</span>(<span class="hljs-params">self</span>):<br> <span class="hljs-string">&quot;&quot;&quot;Common code for GET and HEAD commands.</span><br><span class="hljs-string"> This sends the response code and MIME headers.</span><br><span class="hljs-string"> Return value is either a file object (which has to be copied</span><br><span class="hljs-string"> to the output file by the caller unless the command was HEAD,</span><br><span class="hljs-string"> and must be closed by the caller under all circumstances), or</span><br><span class="hljs-string"> None, in which case the caller has nothing further to do.</span><br><span class="hljs-string"> &quot;&quot;&quot;</span><br> path = translate_path(self.path)<br> <span class="hljs-keyword">if</span> os.path.isdir(path):<br> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> self.path.endswith(<span class="hljs-string">&#x27;/&#x27;</span>):<br> <span class="hljs-comment"># redirect browser - doing basically what apache does</span><br> self.send_response(<span class="hljs-number">301</span>)<br> self.send_header(<span class="hljs-string">&quot;Location&quot;</span>, self.path + <span class="hljs-string">&quot;/&quot;</span>)<br> self.end_headers()<br> <span class="hljs-keyword">return</span> <span class="hljs-literal">None</span><br> <span class="hljs-keyword">for</span> index <span class="hljs-keyword">in</span> <span class="hljs-string">&quot;index.html&quot;</span>, <span class="hljs-string">&quot;index.htm&quot;</span>:<br> index = os.path.join(path, index)<br> <span class="hljs-keyword">if</span> os.path.exists(index):<br> path = index<br> <span class="hljs-keyword">break</span><br> <span class="hljs-keyword">else</span>:<br> <span class="hljs-keyword">return</span> self.list_directory(path)<br> content_type = self.guess_type(path)<br> <span class="hljs-keyword">try</span>:<br> <span class="hljs-comment"># Always read in binary mode. Opening files in text mode may cause</span><br> <span class="hljs-comment"># newline translations, making the actual size of the content</span><br> <span class="hljs-comment"># transmitted *less* than the content-length!</span><br> f = <span class="hljs-built_in">open</span>(path, <span class="hljs-string">&#x27;rb&#x27;</span>)<br> <span class="hljs-keyword">except</span> IOError:<br> self.send_error(<span class="hljs-number">404</span>, <span class="hljs-string">&quot;File not found&quot;</span>)<br> <span class="hljs-keyword">return</span> <span class="hljs-literal">None</span><br> self.send_response(<span class="hljs-number">200</span>)<br> self.send_header(<span class="hljs-string">&quot;Content-type&quot;</span>, content_type)<br> fs = os.fstat(f.fileno())<br> self.send_header(<span class="hljs-string">&quot;Content-Length&quot;</span>, <span class="hljs-built_in">str</span>(fs[<span class="hljs-number">6</span>]))<br> self.send_header(<span class="hljs-string">&quot;Last-Modified&quot;</span>, self.date_time_string(fs.st_mtime))<br> self.end_headers()<br> <span class="hljs-keyword">return</span> f<br><br> <span class="hljs-keyword">def</span> <span class="hljs-title function_">list_directory</span>(<span class="hljs-params">self, path</span>):<br> <span class="hljs-string">&quot;&quot;&quot;Helper to produce a directory listing (absent index.html).</span><br><span class="hljs-string"> Return value is either a file object, or None (indicating an</span><br><span class="hljs-string"> error). In either case, the headers are sent, making the</span><br><span class="hljs-string"> interface the same as for send_head().</span><br><span class="hljs-string"> &quot;&quot;&quot;</span><br> <span class="hljs-keyword">try</span>:<br> list_dir = os.listdir(path)<br> <span class="hljs-keyword">except</span> os.error:<br> self.send_error(<span class="hljs-number">404</span>, <span class="hljs-string">&quot;No permission to list directory&quot;</span>)<br> <span class="hljs-keyword">return</span> <span class="hljs-literal">None</span><br> list_dir.sort(key=<span class="hljs-keyword">lambda</span> a: a.lower())<br> f = BytesIO()<br> display_path = escape(unquote(self.path))<br> f.write(<span class="hljs-string">b&#x27;&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 3.2 Final//EN&quot;&gt;&#x27;</span>)<br> f.write(<span class="hljs-string">b&quot;&lt;html&gt;\n&lt;title&gt;Directory listing for %s&lt;/title&gt;\n&quot;</span> % display_path.encode(<span class="hljs-string">&#x27;utf-8&#x27;</span>))<br> f.write(<span class="hljs-string">b&quot;&lt;body&gt;\n&lt;h2&gt;Directory listing for %s&lt;/h2&gt;\n&quot;</span> % display_path.encode(<span class="hljs-string">&#x27;utf-8&#x27;</span>))<br> f.write(<span class="hljs-string">b&quot;&lt;hr&gt;\n&quot;</span>)<br> f.write(<span class="hljs-string">b&quot;&lt;form ENCTYPE=\&quot;multipart/form-data\&quot; method=\&quot;post\&quot;&gt;&quot;</span>)<br> f.write(<span class="hljs-string">b&quot;&lt;input name=\&quot;file\&quot; type=\&quot;file\&quot;/&gt;&quot;</span>)<br> f.write(<span class="hljs-string">b&quot;&lt;input type=\&quot;submit\&quot; value=\&quot;upload\&quot;/&gt;&lt;/form&gt;\n&quot;</span>)<br> f.write(<span class="hljs-string">b&quot;&lt;hr&gt;\n&lt;ul&gt;\n&quot;</span>)<br> <span class="hljs-keyword">for</span> name <span class="hljs-keyword">in</span> list_dir:<br> fullname = os.path.join(path, name)<br> display_name = linkname = name<br> <span class="hljs-comment"># Append / for directories or @ for symbolic links</span><br> <span class="hljs-keyword">if</span> os.path.isdir(fullname):<br> display_name = name + <span class="hljs-string">&quot;/&quot;</span><br> linkname = name + <span class="hljs-string">&quot;/&quot;</span><br> <span class="hljs-keyword">if</span> os.path.islink(fullname):<br> display_name = name + <span class="hljs-string">&quot;@&quot;</span><br> <span class="hljs-comment"># Note: a link to a directory displays with @ and links with /</span><br> f.write(<span class="hljs-string">b&#x27;&lt;li&gt;&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;\n&#x27;</span> % (quote(linkname).encode(<span class="hljs-string">&#x27;utf-8&#x27;</span>), escape(display_name).encode(<span class="hljs-string">&#x27;utf-8&#x27;</span>)))<br> f.write(<span class="hljs-string">b&quot;&lt;/ul&gt;\n&lt;hr&gt;\n&lt;/body&gt;\n&lt;/html&gt;\n&quot;</span>)<br> length = f.tell()<br> f.seek(<span class="hljs-number">0</span>)<br> self.send_response(<span class="hljs-number">200</span>)<br> self.send_header(<span class="hljs-string">&quot;Content-type&quot;</span>, <span class="hljs-string">&quot;text/html;charset=utf-8&quot;</span>)<br> self.send_header(<span class="hljs-string">&quot;Content-Length&quot;</span>, <span class="hljs-built_in">str</span>(length))<br> self.end_headers()<br> <span class="hljs-keyword">return</span> f<br><br> <span class="hljs-keyword">def</span> <span class="hljs-title function_">guess_type</span>(<span class="hljs-params">self, path</span>):<br> <span class="hljs-string">&quot;&quot;&quot;Guess the type of a file.</span><br><span class="hljs-string"> Argument is a PATH (a filename).</span><br><span class="hljs-string"> Return value is a string of the form type/subtype,</span><br><span class="hljs-string"> usable for a MIME Content-type header.</span><br><span class="hljs-string"> The default implementation looks the file&#x27;s extension</span><br><span class="hljs-string"> up in the table self.extensions_map, using application/octet-stream</span><br><span class="hljs-string"> as a default; however it would be permissible (if</span><br><span class="hljs-string"> slow) to look inside the data to make a better guess.</span><br><span class="hljs-string"> &quot;&quot;&quot;</span><br><br> base, ext = posixpath.splitext(path)<br> <span class="hljs-keyword">if</span> ext <span class="hljs-keyword">in</span> self.extensions_map:<br> <span class="hljs-keyword">return</span> self.extensions_map[ext]<br> ext = ext.lower()<br> <span class="hljs-keyword">if</span> ext <span class="hljs-keyword">in</span> self.extensions_map:<br> <span class="hljs-keyword">return</span> self.extensions_map[ext]<br> <span class="hljs-keyword">else</span>:<br> <span class="hljs-keyword">return</span> self.extensions_map[<span class="hljs-string">&#x27;&#x27;</span>]<br><br> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> mimetypes.inited:<br> mimetypes.init() <span class="hljs-comment"># try to read system mime.types</span><br> extensions_map = mimetypes.types_map.copy()<br> extensions_map.update(&#123;<br> <span class="hljs-string">&#x27;&#x27;</span>: <span class="hljs-string">&#x27;application/octet-stream&#x27;</span>, <span class="hljs-comment"># Default</span><br> <span class="hljs-string">&#x27;.py&#x27;</span>: <span class="hljs-string">&#x27;text/plain&#x27;</span>,<br> <span class="hljs-string">&#x27;.c&#x27;</span>: <span class="hljs-string">&#x27;text/plain&#x27;</span>,<br> <span class="hljs-string">&#x27;.h&#x27;</span>: <span class="hljs-string">&#x27;text/plain&#x27;</span>,<br> &#125;)<br><br><br><span class="hljs-keyword">def</span> <span class="hljs-title function_">translate_path</span>(<span class="hljs-params">path</span>):<br> <span class="hljs-string">&quot;&quot;&quot;Translate a /-separated PATH to the local filename syntax.</span><br><span class="hljs-string"> Components that mean special things to the local file system</span><br><span class="hljs-string"> (e.g. drive or directory names) are ignored. (XXX They should</span><br><span class="hljs-string"> probably be diagnosed.)</span><br><span class="hljs-string"> &quot;&quot;&quot;</span><br> <span class="hljs-comment"># abandon query parameters</span><br> path = path.split(<span class="hljs-string">&#x27;?&#x27;</span>, <span class="hljs-number">1</span>)[<span class="hljs-number">0</span>]<br> path = path.split(<span class="hljs-string">&#x27;#&#x27;</span>, <span class="hljs-number">1</span>)[<span class="hljs-number">0</span>]<br> path = posixpath.normpath(unquote(path))<br> words = path.split(<span class="hljs-string">&#x27;/&#x27;</span>)<br> words = <span class="hljs-built_in">filter</span>(<span class="hljs-literal">None</span>, words)<br> path = os.getcwd()<br> <span class="hljs-keyword">for</span> word <span class="hljs-keyword">in</span> words:<br> drive, word = os.path.splitdrive(word)<br> head, word = os.path.split(word)<br> <span class="hljs-keyword">if</span> word <span class="hljs-keyword">in</span> (os.curdir, os.pardir):<br> <span class="hljs-keyword">continue</span><br> path = os.path.join(path, word)<br> <span class="hljs-keyword">return</span> path<br><br><br><span class="hljs-keyword">def</span> <span class="hljs-title function_">signal_handler</span>(<span class="hljs-params">signal, frame</span>):<br> <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;You choose to stop me.&quot;</span>)<br> exit()<br><br><span class="hljs-keyword">def</span> <span class="hljs-title function_">_argparse</span>():<br> parser = argparse.ArgumentParser()<br> parser.add_argument(<span class="hljs-string">&#x27;--bind&#x27;</span>, <span class="hljs-string">&#x27;-b&#x27;</span>, metavar=<span class="hljs-string">&#x27;ADDRESS&#x27;</span>, default=<span class="hljs-string">&#x27;0.0.0.0&#x27;</span>, <span class="hljs-built_in">help</span>=<span class="hljs-string">&#x27;Specify alternate bind address [default: all interfaces]&#x27;</span>)<br> parser.add_argument(<span class="hljs-string">&#x27;--version&#x27;</span>, <span class="hljs-string">&#x27;-v&#x27;</span>, action=<span class="hljs-string">&#x27;version&#x27;</span>, version=__version__)<br> parser.add_argument(<span class="hljs-string">&#x27;port&#x27;</span>, action=<span class="hljs-string">&#x27;store&#x27;</span>, default=<span class="hljs-number">8000</span>, <span class="hljs-built_in">type</span>=<span class="hljs-built_in">int</span>, nargs=<span class="hljs-string">&#x27;?&#x27;</span>, <span class="hljs-built_in">help</span>=<span class="hljs-string">&#x27;Specify alternate port [default: 8000]&#x27;</span>)<br> <span class="hljs-keyword">return</span> parser.parse_args()<br><br><span class="hljs-keyword">def</span> <span class="hljs-title function_">main</span>():<br> args = _argparse()<br> <span class="hljs-comment"># print(args)</span><br> server_address = (args.bind, args.port)<br> signal.signal(signal.SIGINT, signal_handler)<br> signal.signal(signal.SIGTERM, signal_handler)<br> httpd = HTTPServer(server_address, SimpleHTTPRequestHandler)<br> server = httpd.socket.getsockname()<br> <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;server_version: &quot;</span> + SimpleHTTPRequestHandler.server_version + <span class="hljs-string">&quot;, python_version: &quot;</span> + SimpleHTTPRequestHandler.sys_version)<br> <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;sys encoding: &quot;</span> + sys.getdefaultencoding())<br> <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Serving http on: &quot;</span> + <span class="hljs-built_in">str</span>(server[<span class="hljs-number">0</span>]) + <span class="hljs-string">&quot;, port: &quot;</span> + <span class="hljs-built_in">str</span>(server[<span class="hljs-number">1</span>]) + <span class="hljs-string">&quot; ... (http://&quot;</span> + server[<span class="hljs-number">0</span>] + <span class="hljs-string">&quot;:&quot;</span> + <span class="hljs-built_in">str</span>(server[<span class="hljs-number">1</span>]) + <span class="hljs-string">&quot;/)&quot;</span>)<br> httpd.serve_forever()<br><br><span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">&#x27;__main__&#x27;</span>:<br> main()<br></code></pre></td></tr></table></figure>
  182. <h2 id="附加-集成Shizuku">附加 集成Shizuku</h2>
  183. <ul>
  184. <li><a href="https://hexo.limour.top/go/#aHR0cHM6Ly9kZXZlbG9wZXIuYW5kcm9pZC5jb20vdG9vbHMvcmVsZWFzZXMvcGxhdGZvcm0tdG9vbHM=" rel="noopener external nofollow noreferrer">ADB</a></li>
  185. <li><a href="https://hexo.limour.top/go/#aHR0cHM6Ly9naXRodWIuY29tL1Jpa2thQXBwcy9TaGl6dWt1L3JlbGVhc2Vz" rel="noopener external nofollow noreferrer">Shizuku</a></li>
  186. <li><a href="https://hexo.limour.top/go/#aHR0cHM6Ly9naXRodWIuY29tL01hWWlGZWkxOTk1L1BhY2thZ2VWaWV3ZXIvcmVsZWFzZXM=" rel="noopener external nofollow noreferrer">PackageViewer</a></li>
  187. </ul>
  188. <figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs powershell">adb devices<br>.\adb.exe install <span class="hljs-literal">-t</span> <span class="hljs-string">&#x27;.\termux.apk&#x27;</span><br>.\adb.exe install <span class="hljs-literal">-t</span> <span class="hljs-string">&#x27;.\shizuku.apk&#x27;</span><br><br>adb shell<br>sh /storage/emulated/<span class="hljs-number">0</span>/Android/<span class="hljs-keyword">data</span>/moe.shizuku.privileged.api/start.sh<br></code></pre></td></tr></table></figure>
  189. <ul>
  190. <li>在<code>Shizuku-在终端应用中使用Shizuku</code>中导出<code>rish</code>文件到<code>termux</code></li>
  191. <li>修改<code>rish</code>文件中的<code>&quot;PKG&quot;</code>为<code>&quot;com.termux&quot;</code></li>
  192. <li>在<code>termux</code>中运行<code>sh rish</code>进入<code>adb shell</code></li>
  193. </ul>
  194. <figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs adb">pm disable-user --user 0 com.android.browser<br></code></pre></td></tr></table></figure>
  195. </div>
  196. <hr/>
  197. <div>
  198. <div class="post-metas my-3">
  199. <div class="post-meta">
  200. <i class="iconfont icon-tags"></i>
  201. <a href="/tags/termux/" class="print-no-link">#termux</a>
  202. <a href="/tags/ssh/" class="print-no-link">#ssh</a>
  203. </div>
  204. </div>
  205. <div class="license-box my-3">
  206. <div class="license-title">
  207. <div>【记录】使用 Termux 作为 SSH 客户端</div>
  208. <div>https://hexo.limour.top/-ji-lu--shi-yong-Termux-zuo-wei-SSH-ke-hu-duan</div>
  209. </div>
  210. <div class="license-meta">
  211. <div class="license-meta-item">
  212. <div>Author</div>
  213. <div>Limour</div>
  214. </div>
  215. <div class="license-meta-item license-meta-date">
  216. <div>Posted on</div>
  217. <div>July 22, 2023</div>
  218. </div>
  219. <div class="license-meta-item license-meta-date">
  220. <div>Updated on</div>
  221. <div>March 19, 2024</div>
  222. </div>
  223. <div class="license-meta-item">
  224. <div>Licensed under</div>
  225. <div>
  226. <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  227. <span class="hint--top hint--rounded" aria-label="BY - Attribution">
  228. <i class="iconfont icon-cc-by"></i>
  229. </span>
  230. </a>
  231. <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  232. <span class="hint--top hint--rounded" aria-label="NC - Non-commercial">
  233. <i class="iconfont icon-cc-nc"></i>
  234. </span>
  235. </a>
  236. <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  237. <span class="hint--top hint--rounded" aria-label="SA - Share-alike">
  238. <i class="iconfont icon-cc-sa"></i>
  239. </span>
  240. </a>
  241. </div>
  242. </div>
  243. </div>
  244. <div class="license-icon iconfont"></div>
  245. </div>
  246. <div class="post-prevnext my-3">
  247. <article class="post-prev col-6">
  248. <a href="/-ji-lu-GOST-jin-xing-SOCKS5-de-fu-zai-jun-heng" title="【记录】GOST 进行 SOCKS5 的负载均衡">
  249. <i class="iconfont icon-arrowleft"></i>
  250. <span class="hidden-mobile">【记录】GOST 进行 SOCKS5 的负载均衡</span>
  251. <span class="visible-mobile">Previous</span>
  252. </a>
  253. </article>
  254. <article class="post-next col-6">
  255. <a href="/-ji-lu--shi-yong-tdl-xia-zai-Telegram-zhong-de-shi-pin" title="【记录】使用 tdl 下载 Telegram 中的视频">
  256. <span class="hidden-mobile">【记录】使用 tdl 下载 Telegram 中的视频</span>
  257. <span class="visible-mobile">Next</span>
  258. <i class="iconfont icon-arrowright"></i>
  259. </a>
  260. </article>
  261. </div>
  262. </div>
  263. <article id="comments" lazyload>
  264. <div id="waline"></div>
  265. <script type="text/javascript">
  266. Fluid.utils.loadComments('#waline', function() {
  267. Fluid.utils.createCssLink('https://cdn.staticfile.org/waline/2.15.5/waline.css')
  268. Fluid.utils.createScript('https://cdn.staticfile.org/waline/2.15.5/waline.js', function() {
  269. var options = Object.assign(
  270. {"serverURL":"https://comments.limour.top","path":"window.location.pathname","meta":["nick","mail","link"],"requiredMeta":["nick"],"lang":"zh-CN","emoji":["https://jscdn.limour.top/gh/walinejs/emojis/weibo"],"dark":"html[data-user-color-scheme=\"dark\"]","wordLimit":0,"pageSize":10},
  271. {
  272. el: '#waline',
  273. path: window.location.pathname
  274. }
  275. )
  276. Waline.init(options);
  277. Fluid.utils.waitElementVisible('#waline .vcontent', () => {
  278. var imgSelector = '#waline .vcontent img:not(.vemoji)';
  279. Fluid.plugins.imageCaption(imgSelector);
  280. Fluid.plugins.fancyBox(imgSelector);
  281. })
  282. });
  283. });
  284. </script>
  285. <noscript>Please enable JavaScript to view the comments</noscript>
  286. </article>
  287. </article>
  288. </div>
  289. </div>
  290. </div>
  291. <div class="side-col d-none d-lg-block col-lg-2">
  292. <aside class="sidebar" style="margin-left: -1rem">
  293. <div id="toc">
  294. <p class="toc-header">
  295. <i class="iconfont icon-list"></i>
  296. <span>Table of Contents</span>
  297. </p>
  298. <div class="toc-body" id="toc-body"></div>
  299. </div>
  300. </aside>
  301. </div>
  302. </div>
  303. </div>
  304. <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
  305. <i class="iconfont icon-arrowup" aria-hidden="true"></i>
  306. </a>
  307. <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
  308. aria-hidden="true">
  309. <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
  310. <div class="modal-content">
  311. <div class="modal-header text-center">
  312. <h4 class="modal-title w-100 font-weight-bold">Search</h4>
  313. <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
  314. <span aria-hidden="true">&times;</span>
  315. </button>
  316. </div>
  317. <div class="modal-body mx-3">
  318. <div class="md-form mb-5">
  319. <input type="text" id="local-search-input" class="form-control validate">
  320. <label data-error="x" data-success="v" for="local-search-input">Keyword</label>
  321. </div>
  322. <div class="list-group" id="local-search-result"></div>
  323. </div>
  324. </div>
  325. </div>
  326. </div>
  327. </main>
  328. <footer>
  329. <div class="footer-inner">
  330. <div class="footer-content">
  331. <a target="_blank" rel="nofollow noopener" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=43130202000203"><img src="https://img.limour.top/2023/08/27/64eadeb81d6a0.webp" srcset="https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg" lazyload>湘公网安备43130202000203号 </a> <a target="_blank" rel="nofollow noopener" href="https://beian.miit.gov.cn/">湘ICP备20008299号 </a> <a target="_blank" rel="nofollow noopener" href="https://icp.gov.moe/?keyword=20210128">萌ICP备20210128号</a> <br> <a href="https://www.foreverblog.cn/" target="_blank"> <img src="https://img.foreverblog.cn/logo_en_default.png" srcset="https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg" lazyload alt="" style="width:auto;height:24px"> </a> <br> <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/limour-blog/limour-blog.github.io" target="_blank" rel="nofollow noopener"><span>SRC</span></a> <i class="iconfont icon-love"></i> <a href="https://web.archive.org/web/20231130095837/https://effectiveacceleration.tech/" target="_blank" rel="nofollow noopener"><span>e/Acc</span></a>
  332. </div>
  333. </div>
  334. </footer>
  335. <!-- Scripts -->
  336. <script src="https://jscdn.limour.top/npm/nprogress@0.2.0/nprogress.min.js" ></script>
  337. <link rel="stylesheet" href="https://jscdn.limour.top/npm/nprogress@0.2.0/nprogress.min.css" />
  338. <script>
  339. NProgress.configure({"showSpinner":false,"trickleSpeed":100})
  340. NProgress.start()
  341. window.addEventListener('load', function() {
  342. NProgress.done();
  343. })
  344. </script>
  345. <script src="https://jscdn.limour.top/npm/jquery@3.6.4/dist/jquery.min.js" ></script>
  346. <script src="https://jscdn.limour.top/npm/bootstrap@4.6.1/dist/js/bootstrap.min.js" ></script>
  347. <script src="/js/events.js" ></script>
  348. <script src="/js/plugins.js" ></script>
  349. <script src="/js/img-lazyload.js" ></script>
  350. <script>
  351. Fluid.utils.createScript('https://jscdn.limour.top/npm/tocbot@4.20.1/dist/tocbot.min.js', function() {
  352. var toc = jQuery('#toc');
  353. if (toc.length === 0 || !window.tocbot) { return; }
  354. var boardCtn = jQuery('#board-ctn');
  355. var boardTop = boardCtn.offset().top;
  356. window.tocbot.init(Object.assign({
  357. tocSelector : '#toc-body',
  358. contentSelector : '.markdown-body',
  359. linkClass : 'tocbot-link',
  360. activeLinkClass : 'tocbot-active-link',
  361. listClass : 'tocbot-list',
  362. isCollapsedClass: 'tocbot-is-collapsed',
  363. collapsibleClass: 'tocbot-is-collapsible',
  364. scrollSmooth : true,
  365. includeTitleTags: true,
  366. headingsOffset : -boardTop,
  367. }, CONFIG.toc));
  368. if (toc.find('.toc-list-item').length > 0) {
  369. toc.css('visibility', 'visible');
  370. }
  371. Fluid.events.registerRefreshCallback(function() {
  372. if ('tocbot' in window) {
  373. tocbot.refresh();
  374. var toc = jQuery('#toc');
  375. if (toc.length === 0 || !tocbot) {
  376. return;
  377. }
  378. if (toc.find('.toc-list-item').length > 0) {
  379. toc.css('visibility', 'visible');
  380. }
  381. }
  382. });
  383. });
  384. </script>
  385. <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>
  386. <script>Fluid.plugins.codeWidget();</script>
  387. <script>
  388. Fluid.utils.createScript('https://jscdn.limour.top/npm/anchor-js@4.3.1/anchor.min.js', function() {
  389. window.anchors.options = {
  390. placement: CONFIG.anchorjs.placement,
  391. visible : CONFIG.anchorjs.visible
  392. };
  393. if (CONFIG.anchorjs.icon) {
  394. window.anchors.options.icon = CONFIG.anchorjs.icon;
  395. }
  396. var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
  397. var res = [];
  398. for (var item of el) {
  399. res.push('.markdown-body > ' + item.trim());
  400. }
  401. if (CONFIG.anchorjs.placement === 'left') {
  402. window.anchors.options.class = 'anchorjs-link-left';
  403. }
  404. window.anchors.add(res.join(', '));
  405. Fluid.events.registerRefreshCallback(function() {
  406. if ('anchors' in window) {
  407. anchors.removeAll();
  408. var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
  409. var res = [];
  410. for (var item of el) {
  411. res.push('.markdown-body > ' + item.trim());
  412. }
  413. if (CONFIG.anchorjs.placement === 'left') {
  414. anchors.options.class = 'anchorjs-link-left';
  415. }
  416. anchors.add(res.join(', '));
  417. }
  418. });
  419. });
  420. </script>
  421. <script>Fluid.plugins.imageCaption();</script>
  422. <script src="/js/local-search.js" ></script>
  423. <!-- 主题的启动项,将它保持在最底部 -->
  424. <!-- the boot of the theme, keep it at the bottom -->
  425. <script src="/js/boot.js" ></script>
  426. <noscript>
  427. <div class="noscript-warning">Blog works best with JavaScript enabled</div>
  428. </noscript>
  429. <!-- hexo injector body_end start -->
  430. <script defer src="/theme-inject/timeliness.js"></script>
  431. <!-- hexo injector body_end end --></body>
  432. </html>