Skip to content

Commit

Permalink
Site updated: 2023-11-13 00:29:18
Browse files Browse the repository at this point in the history
  • Loading branch information
forfreeday committed Nov 12, 2023
1 parent 09ad4ea commit f90f973
Show file tree
Hide file tree
Showing 967 changed files with 2,819 additions and 2,766 deletions.
4 changes: 2 additions & 2 deletions 404.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions about/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions all-archives/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions all-categories/index.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions all-tags/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2013/11/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2013/12/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2013/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2014/04/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2014/06/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2014/08/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2014/09/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2014/10/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2014/12/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2014/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2014/page/2/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2015/01/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2015/02/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2015/03/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2015/04/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2015/05/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2015/06/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2015/07/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2015/08/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2015/10/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2015/11/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2015/12/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2015/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2015/page/2/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2015/page/3/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2015/page/4/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2016/01/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2016/02/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2016/03/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2016/04/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2016/05/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2016/06/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2016/07/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2016/08/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2016/09/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2016/10/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2016/11/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2016/12/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2016/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2016/page/2/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2016/page/3/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2016/page/4/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2017/01/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2017/02/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2017/03/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2017/04/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2017/05/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2017/06/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2017/07/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2017/08/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2017/09/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2017/10/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2017/11/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2017/12/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2017/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2017/page/2/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2017/page/3/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2017/page/4/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2018/02/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2018/04/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2018/05/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2018/07/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2018/07/page/2/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2018/08/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2018/09/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2018/10/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2018/11/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2018/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2018/page/2/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2018/page/3/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2019/01/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2019/02/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2019/03/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2019/04/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2019/05/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2019/06/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2019/07/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2019/11/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2019/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2019/page/2/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2019/page/3/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2020/03/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2020/05/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2020/07/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2020/12/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2020/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2021/01/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2021/04/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2021/05/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2021/07/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2021/10/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2021/11/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2021/11/page/2/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2021/12/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2021/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2021/page/2/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2021/page/3/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2021/page/4/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/01/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/01/page/2/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/02/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/03/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/03/page/2/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/04/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/05/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/06/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/07/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/08/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/09/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/10/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/11/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/12/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/page/2/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/page/3/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/page/4/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/page/5/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2022/page/6/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2023/01/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2023/02/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2023/03/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2023/04/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2023/05/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2023/06/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2023/09/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2023/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/2023/page/2/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/10/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/11/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/12/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/13/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/14/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/15/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/16/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/17/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/18/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/19/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/2/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/20/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/21/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/22/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/23/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/24/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/25/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/26/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/27/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/28/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/29/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/3/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/30/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/4/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/5/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/6/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/7/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/8/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions archives/page/9/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions atom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,12 @@

<category term="tron" scheme="https://liukai.net/tags/tron/"/>

<category term="波场" scheme="https://liukai.net/tags/%E6%B3%A2%E5%9C%BA/"/>

<category term="witness" scheme="https://liukai.net/tags/witness/"/>

<category term="加载" scheme="https://liukai.net/tags/%E5%8A%A0%E8%BD%BD/"/>

<category term="波场" scheme="https://liukai.net/tags/%E6%B3%A2%E5%9C%BA/"/>

</entry>

<entry>
Expand Down Expand Up @@ -537,7 +537,7 @@
<published>2022-12-15T12:27:13.000Z</published>
<updated>2023-08-29T09:25:37.069Z</updated>

<content type="html"><![CDATA[<h2 id="需求"><a href="#需求" class="headerlink" title="需求"></a>需求</h2><p>需求很简单,通过脚本自动登陆跳板机。<br>因为最近换的是mac M2,然后碰到了一堆问题。</p><h2 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h2><p>从<strong>intel</strong>芯片换到<strong>m2</strong>出现很多问题。<br>首先mac m2 没有python2,默认是python3,所以脚本的命令要调整成python3相关的。<br>然后是 ssh 登陆,原来正常可以登陆方式也有问题,默认的ssh密钥失效,需要替换成新的密钥。<br>就导致原来的免密登陆也失效了,添加了公钥,依然需要输密码,下面的脚本,有一段是补偿输入密码的操作,<br>如果不需要,可以删了输密码的部份。</p><h2 id="自动登陆脚本"><a href="#自动登陆脚本" class="headerlink" title="自动登陆脚本"></a>自动登陆脚本</h2><p>需要准备两个脚本:</p><ol><li>login.sh, shell 脚本</li><li>jump.python, python3脚本</li></ol><figure class="highlight shell"><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></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">!/bin/sh</span></span><br><span class="line">expect -c &quot;</span><br><span class="line">set pwd you_pass_word</span><br><span class="line">spawn ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa [email protected]</span><br><span class="line">set timeout 2</span><br><span class="line">expect &quot;*assword:*&quot;</span><br><span class="line">send \&quot;\$pwd\r\&quot;</span><br><span class="line"></span><br><span class="line">set timeout 2</span><br><span class="line">expect \&quot;\[MFA auth\]:\&quot;</span><br><span class="line">set password \&quot;`python3 ~/.ssh/jump.python`\&quot;</span><br><span class="line">send \&quot;\$password\r\&quot;</span><br><span class="line">interact</span><br><span class="line">&quot;</span><br></pre></td></tr></table></figure><h3 id="解释上面的脚本"><a href="#解释上面的脚本" class="headerlink" title="解释上面的脚本"></a>解释上面的脚本</h3><p>说明一下,新的 ssh 需要输入:</p><blockquote><p>ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa</p></blockquote><p>原来 ssh 只需要:</p><blockquote><p>ssh <a href="mailto:&#x75;&#115;&#101;&#x72;&#110;&#x61;&#109;&#x65;&#64;&#x31;&#48;&#x2e;&#49;&#48;&#46;&#x31;&#48;&#x2e;&#x31;&#48;">&#x75;&#115;&#101;&#x72;&#110;&#x61;&#109;&#x65;&#64;&#x31;&#48;&#x2e;&#49;&#48;&#46;&#x31;&#48;&#x2e;&#x31;&#48;</a> 就可以登陆了</p></blockquote><h2 id="python3-部分"><a href="#python3-部分" class="headerlink" title="python3 部分"></a>python3 部分</h2><p>python3 脚本提取google验证码。</p><p><code>my_secret</code> 是谷歌的密钥。</p><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></pre></td><td class="code"><pre><span class="line"><span class="comment">#!/usr/bin/python3</span></span><br><span class="line"><span class="keyword">import</span> onetimepass <span class="keyword">as</span> otp</span><br><span class="line"></span><br><span class="line">my_secret = <span class="string">&#x27;XXXXXXXXXXXXX&#x27;</span></span><br><span class="line">my_token = otp.get_totp(my_secret)</span><br><span class="line"><span class="keyword">print</span> (<span class="string">&quot;%06d&quot;</span> % my_token)</span><br></pre></td></tr></table></figure><h2 id="iterm2-配置"><a href="#iterm2-配置" class="headerlink" title="iterm2 配置"></a>iterm2 配置</h2><p>在 Open Profiles 中添加一下自动登陆脚本:</p><p><img src="/posts/95f16259/iterm2%E8%87%AA%E5%8A%A8%E7%99%BB%E9%99%86%E9%85%8D%E7%BD%AE.jpg" alt="iterm2自动登陆配置.jpg"></p><p>login shell 或 Command 都可以,用<code>sh</code>:</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sh ~/.ssh/jump.sh</span><br></pre></td></tr></table></figure><p>不要使用 <code>expect</code> 开头:</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">expect ~/.ssh/jump.sh</span><br></pre></td></tr></table></figure><p>这样就可以登陆成功了,即不需要输密码,也不需要验证码。<br>需要注意的是,如果需要使用<code>lrzsz</code> 这样的功能的话,不可以使用<code>expect</code>执行脚本,会失败,只能使用<code>sh</code>进行登陆。</p>]]></content>
<content type="html"><![CDATA[<h2 id="需求"><a href="#需求" class="headerlink" title="需求"></a>需求</h2><p>需求很简单,通过脚本自动登陆跳板机。<br>因为最近换的是mac M2,然后碰到了一堆问题。</p><h2 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h2><p>从<strong>intel</strong>芯片换到<strong>m2</strong>出现很多问题。<br>首先mac m2 没有python2,默认是python3,所以脚本的命令要调整成python3相关的。<br>然后是 ssh 登陆,原来正常可以登陆方式也有问题,默认的ssh密钥失效,需要替换成新的密钥。<br>就导致原来的免密登陆也失效了,添加了公钥,依然需要输密码,下面的脚本,有一段是补偿输入密码的操作,<br>如果不需要,可以删了输密码的部份。</p><h2 id="自动登陆脚本"><a href="#自动登陆脚本" class="headerlink" title="自动登陆脚本"></a>自动登陆脚本</h2><p>需要准备两个脚本:</p><ol><li>login.sh, shell 脚本</li><li>jump.python, python3脚本</li></ol><figure class="highlight shell"><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></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash">!/bin/sh</span></span><br><span class="line">expect -c &quot;</span><br><span class="line">set pwd you_pass_word</span><br><span class="line">spawn ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa [email protected]</span><br><span class="line">set timeout 2</span><br><span class="line">expect &quot;*assword:*&quot;</span><br><span class="line">send \&quot;\$pwd\r\&quot;</span><br><span class="line"></span><br><span class="line">set timeout 2</span><br><span class="line">expect \&quot;\[MFA auth\]:\&quot;</span><br><span class="line">set password \&quot;`python3 ~/.ssh/jump.python`\&quot;</span><br><span class="line">send \&quot;\$password\r\&quot;</span><br><span class="line">interact</span><br><span class="line">&quot;</span><br></pre></td></tr></table></figure><h3 id="解释上面的脚本"><a href="#解释上面的脚本" class="headerlink" title="解释上面的脚本"></a>解释上面的脚本</h3><p>说明一下,新的 ssh 需要输入:</p><blockquote><p>ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa</p></blockquote><p>原来 ssh 只需要:</p><blockquote><p>ssh <a href="mailto:&#117;&#x73;&#x65;&#114;&#110;&#97;&#x6d;&#x65;&#64;&#49;&#48;&#46;&#49;&#x30;&#x2e;&#49;&#x30;&#x2e;&#x31;&#x30;">&#117;&#x73;&#x65;&#114;&#110;&#97;&#x6d;&#x65;&#64;&#49;&#48;&#46;&#49;&#x30;&#x2e;&#49;&#x30;&#x2e;&#x31;&#x30;</a> 就可以登陆了</p></blockquote><h2 id="python3-部分"><a href="#python3-部分" class="headerlink" title="python3 部分"></a>python3 部分</h2><p>python3 脚本提取google验证码。</p><p><code>my_secret</code> 是谷歌的密钥。</p><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></pre></td><td class="code"><pre><span class="line"><span class="comment">#!/usr/bin/python3</span></span><br><span class="line"><span class="keyword">import</span> onetimepass <span class="keyword">as</span> otp</span><br><span class="line"></span><br><span class="line">my_secret = <span class="string">&#x27;XXXXXXXXXXXXX&#x27;</span></span><br><span class="line">my_token = otp.get_totp(my_secret)</span><br><span class="line"><span class="keyword">print</span> (<span class="string">&quot;%06d&quot;</span> % my_token)</span><br></pre></td></tr></table></figure><h2 id="iterm2-配置"><a href="#iterm2-配置" class="headerlink" title="iterm2 配置"></a>iterm2 配置</h2><p>在 Open Profiles 中添加一下自动登陆脚本:</p><p><img src="/posts/95f16259/iterm2%E8%87%AA%E5%8A%A8%E7%99%BB%E9%99%86%E9%85%8D%E7%BD%AE.jpg" alt="iterm2自动登陆配置.jpg"></p><p>login shell 或 Command 都可以,用<code>sh</code>:</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sh ~/.ssh/jump.sh</span><br></pre></td></tr></table></figure><p>不要使用 <code>expect</code> 开头:</p><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">expect ~/.ssh/jump.sh</span><br></pre></td></tr></table></figure><p>这样就可以登陆成功了,即不需要输密码,也不需要验证码。<br>需要注意的是,如果需要使用<code>lrzsz</code> 这样的功能的话,不可以使用<code>expect</code>执行脚本,会失败,只能使用<code>sh</code>进行登陆。</p>]]></content>

<summary type="html">

Expand Down
Loading

0 comments on commit f90f973

Please sign in to comment.