-
Notifications
You must be signed in to change notification settings - Fork 0
/
atom.xml
122 lines (60 loc) · 20.1 KB
/
atom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>LLmons' House</title>
<link href="http://llmons.top/atom.xml" rel="self"/>
<link href="http://llmons.top/"/>
<updated>2024-09-21T05:45:30.432Z</updated>
<id>http://llmons.top/</id>
<author>
<name>llmons</name>
</author>
<generator uri="https://hexo.io/">Hexo</generator>
<entry>
<title>SSH远程登录</title>
<link href="http://llmons.top/2024/09/21/sshRemoteLogin/"/>
<id>http://llmons.top/2024/09/21/sshRemoteLogin/</id>
<published>2024-09-21T05:45:30.000Z</published>
<updated>2024-09-21T05:45:30.432Z</updated>
<content type="html"><![CDATA[<h1 id="SSH远程登录"><a href="#SSH远程登录" class="headerlink" title=" SSH远程登录"></a><center> SSH远程登录</h1><h3 id="什么是SSH?"><a href="#什么是SSH?" class="headerlink" title="什么是SSH?"></a>什么是SSH?</h3><p><a href="https://zh.wikipedia.org/wiki/Secure_Shell">SSH</a>(Secure Shell Protocol)是一个是一种加密的网络传输<strong>协议</strong>,是一个Protocol,它有具体实现,比如开源的<a href="https://www.openssh.com/">openSSH</a>。SSH通过在网络中建立安全隧道来实现SSH客户端与服务器之间的连接,可在不安全的网络中为网络服务提供安全的传输环境,SSH最常见的用途是远程登录系统。</p><h3 id="连接的整个过程"><a href="#连接的整个过程" class="headerlink" title="连接的整个过程"></a>连接的整个过程</h3><ol><li><strong>建立连接</strong> SSH是基于TCP/IP协议的,所以最开始的时候要先进行TCP3次握手</li><li><strong>版本协商</strong> SSH目前有SSH-1和SSH-2两个版本,加密方式不同,需要预先协商使用的版本</li><li><strong>算法协商</strong> 协商使用哪种加密算法,如 RSA,ED25519</li><li><strong>密钥交换</strong> 使用<a href="https://zh.wikipedia.org/wiki/%E8%BF%AA%E8%8F%B2-%E8%B5%AB%E7%88%BE%E6%9B%BC%E5%AF%86%E9%91%B0%E4%BA%A4%E6%8F%9B">DH密钥交换算法</a>(Diffie–Hellman key exchange)生成共享密钥。过程如下<br><br><code>首先客户端生成公钥pk1,私钥sk1,然后将pk1发送给服务端</code><br><br><code>服务端生成服务端自己的公钥pk2,私钥sk2,然后服务端使用pk2,sk2,pk1生成了共享密钥ss1</code><br><br><code>接着服务端不会直接发送ss1给客户端,而是发送pk2给客户端,也就是也将自己的公钥发送给对方</code><br><br><code>客户端收到pk2后,使用pk1,sk1,pk2生成了共享密钥ss2,DH算法证明,ss1和ss2是一样的share secret</code><br><br>那么这个时候就可以使用由非对称加密得到的共享密钥,同时也是会话密钥(Session Key),这个密钥就可以作为后续通信的对称密钥了。注意以上的过程中的客户端服务端生成的公钥私钥都为<strong>临时密钥</strong></li><li><strong>身份认证</strong> 可以使用密码认证,也可以使用密钥认证。<br><br>密码认证<strong>不安全</strong>,可能会被截取破解。<br><br>若使用密钥认证,首先服务端得有客户端复制而来的公钥,接下来有如下过程<br><code>首先客户端发出连接request,服务端收到request后生成随机数R,使用公钥生成密文并发送给客户端</code><br><br><code>客户端收到密文后使用私钥解密得到随机数R,接着使用Session Key对R进行哈希得到数据摘要Digest1并发送给服务端</code><br><br><code>服务端收到Digest1,同时服务端使用Session Key对R进行哈希得到Digest2,如果Digest1=Digest2,验证通过</code><br>整个过程相比于密码登录,更为安全</li><li><strong>会话请求</strong> 在身份认证成功后,客户端向服务器发送会话请求。此时,客户端会使用会<code>Session Key</code>用于对后续传输的数据进行加密。</li><li><strong>信息通讯</strong> 会话建立后,就可以进行通信。由于只有客户端和服务器能够解密和理解这些信息,即使在不安全的网络环境中,数据仍然可以保持机密。</li></ol><h3 id="ssh远程登录"><a href="#ssh远程登录" class="headerlink" title="ssh远程登录"></a>ssh远程登录</h3><p>使用命令<code>ssh <user>@<host></code><br><br>比如,以root用户登录ip为1.1.1.1的主机</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh [email protected]</span><br></pre></td></tr></table></figure><p>ssh登录端口默认22,还可以指定端口,使用<code>-p</code>参数<br>比如,以git用户登录ip为2.2.2.2的主机</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">ssh [email protected] -p 22</span><br></pre></td></tr></table></figure><p>如果没用密钥认证,接下去会让你输入密码</p><h3 id="密钥认证免密登录"><a href="#密钥认证免密登录" class="headerlink" title="密钥认证免密登录"></a>密钥认证免密登录</h3><ol><li><p>客户端生成公钥和私钥,使用命令<code>ssh-keygen</code> <br><br>常用可选参数如下:</p><table><thead><tr><th align="center">参数</th><th align="center">作用</th></tr></thead><tbody><tr><td align="center">-t</td><td align="center">type,指定加密算法</td></tr><tr><td align="center">-C</td><td align="center">comment,备注信息</td></tr><tr><td align="center">-f</td><td align="center">filename,指定密钥储存文件的文件名</td></tr><tr><td align="center">-N</td><td align="center">new_passphrase,指定新的密码</td></tr><tr><td align="center">-q</td><td align="center">quiet,静默模式,不显示输出</td></tr></tbody></table><p> 比如,使用命令</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">ssh-keygen -t ed25519</span><br></pre></td></tr></table></figure><p> 这时会在<code>~/.ssh/</code>下生成两个文件<code>id_ed25519</code>和<code>id_ed25519.pub</code>,分别储存着私钥和公钥</p></li><li><p>接着使用命令<code>ssh-copy-id <user>@<host></code>将公钥复制到服务端<br>比如</p><pre><code>ssh-copy-id [email protected]</code></pre><p>将会把公钥复制到服务端的<code>~/.ssh/authorized_keys</code>下</p><p>后续再使用ssh登录时就不用再输入密码</p></li></ol>]]></content>
<summary type="html"><h1 id="SSH远程登录"><a href="#SSH远程登录" class="headerlink" title=" SSH远程登录"></a><center> SSH远程登录</h1><h3 id="什么是SSH?"><a href="#什么是SSH?" class="</summary>
<category term="Linux" scheme="http://llmons.top/tags/Linux/"/>
</entry>
<entry>
<title>sr-only</title>
<link href="http://llmons.top/2024/08/08/sr-only/"/>
<id>http://llmons.top/2024/08/08/sr-only/</id>
<published>2024-08-08T11:07:42.000Z</published>
<updated>2024-08-08T11:07:42.000Z</updated>
<content type="html"><![CDATA[<p>  使用<code>sr-only</code>样式的目的是将内容从视觉上隐藏,但是仍然让 <code>Screen Reader</code> 可读。这对视觉障碍者提供了额外的信息,增强了<code>Accessibility</code>,同时对<code>SEO</code>友好。</p><figure class="highlight css"><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></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.sr-only</span>{</span><br><span class="line"> <span class="attribute">position</span>:absolute;</span><br><span class="line"> <span class="attribute">width</span>:<span class="number">1px</span>;</span><br><span class="line"> <span class="attribute">height</span>:<span class="number">1px</span>;</span><br><span class="line"> <span class="attribute">padding</span>:<span class="number">0</span>;</span><br><span class="line"> <span class="attribute">margin</span>:-<span class="number">1px</span>;</span><br><span class="line"> <span class="attribute">overflow</span>:hidden;</span><br><span class="line"> <span class="attribute">clip</span>:<span class="built_in">rect</span>(<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>);</span><br><span class="line"> <span class="attribute">white-space</span>:nowrap;</span><br><span class="line"> <span class="attribute">border</span>:<span class="number">0</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure>]]></content>
<summary type="html"><p>&ensp;&ensp;使用<code>sr-only</code>样式的目的是将内容从视觉上隐藏,但是仍然让 <code>Screen Reader</code> 可读。这对视觉障碍者提供了额外的信息,增强了<code>Accessibility</code>,同时对<c</summary>
<category term="Web开发" scheme="http://llmons.top/categories/Web%E5%BC%80%E5%8F%91/"/>
<category term="笔记" scheme="http://llmons.top/tags/%E7%AC%94%E8%AE%B0/"/>
<category term="css" scheme="http://llmons.top/tags/css/"/>
<category term="前端" scheme="http://llmons.top/tags/%E5%89%8D%E7%AB%AF/"/>
<category term="Web开发" scheme="http://llmons.top/tags/Web%E5%BC%80%E5%8F%91/"/>
</entry>
<entry>
<title>一些算法中常用的coding技巧</title>
<link href="http://llmons.top/2024/07/18/%E4%B8%80%E4%BA%9B%E7%AE%97%E6%B3%95%E4%B8%AD%E5%B8%B8%E7%94%A8%E7%9A%84coding%E6%8A%80%E5%B7%A7/"/>
<id>http://llmons.top/2024/07/18/%E4%B8%80%E4%BA%9B%E7%AE%97%E6%B3%95%E4%B8%AD%E5%B8%B8%E7%94%A8%E7%9A%84coding%E6%8A%80%E5%B7%A7/</id>
<published>2024-07-18T12:39:55.000Z</published>
<updated>2024-08-08T10:51:02.000Z</updated>
<content type="html"><![CDATA[<h2 id="写一些学算法时收获的-coding-小技巧"><a href="#写一些学算法时收获的-coding-小技巧" class="headerlink" title="写一些学算法时收获的 coding 小技巧"></a>写一些学算法时收获的 coding 小技巧</h2><h3 id="不等于-1"><a href="#不等于-1" class="headerlink" title="不等于 -1"></a>不等于 -1</h3><p>在记忆化搜索中通常会有一个 memo 数组,最初的时候 memo 会全被初始化为-1,代码中有时会这么写</p><figure class="highlight cpp"><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></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="type">void</span> <span class="title">dfs</span><span class="params">(<span class="type">int</span> i)</span></span>{</span><br><span class="line"> <span class="keyword">if</span>(i>n){</span><br><span class="line"> <span class="built_in">cal</span>();</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(memo[i][j]!=<span class="number">-1</span>){</span><br><span class="line"> <span class="built_in">cal</span>();</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line"> }</span><br><span class="line"> <span class="built_in">dfs</span>(i<span class="number">+1</span>);</span><br><span class="line">}</span><br></pre></td></tr></table></figure><p>那么这个记忆化判断部分<code>if(memo[i][j]!=-1)</code>,<br><br>完全可以写成<code>if(~memo[i][j])</code>.<br></p><p>其中的原理:-1的二进制为 <em>1000 0001</em> ,其在计算机中存储为补码形式,即 <em>1111 1111</em> ,<code>~</code>运算取反,-1会运算成0,其他数则会运算为非0,那么<code>if(~memo[i][j])</code>就是表示除了-1均通过</p><h3 id="向下取整(仅限JavaScript)"><a href="#向下取整(仅限JavaScript)" class="headerlink" title="向下取整(仅限JavaScript)"></a>向下取整(仅限JavaScript)</h3><p>js是弱类型语言,在进行一些运算时会进行隐式类型转换,那么来这么一个式子:<br><code>x=~~x;</code><br><br>就可以实现向下取整,因为若右侧x为浮点数,在js中x用64位来储存,在使用位运算后,x就会变成32位整型,此时,小数点后面部分被舍弃,接着再来一次<code>~</code>,就可以返回原来的数。</p><p>举个例子,</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">x=-6.9;</span><br><span class="line">~x=5; // 运算时先截掉后面的0.9,然后x变为-6,取反为5</span><br><span class="line">~~x=-6 // 5再取反就变成了-6</span><br></pre></td></tr></table></figure><p>其实知道原理之后还可以使用如 <code>x=x|0;</code>这样的式子来向下取整。</p><p>注意以上只能用于js,其他强类型语言会报错或者运算错误。</p>]]></content>
<summary type="html"><h2 id="写一些学算法时收获的-coding-小技巧"><a href="#写一些学算法时收获的-coding-小技巧" class="headerlink" title="写一些学算法时收获的 coding 小技巧"></a>写一些学算法时收获的 coding 小技巧</</summary>
<category term="算法" scheme="http://llmons.top/categories/%E7%AE%97%E6%B3%95/"/>
<category term="技巧" scheme="http://llmons.top/tags/%E6%8A%80%E5%B7%A7/"/>
<category term="cpp" scheme="http://llmons.top/tags/cpp/"/>
<category term="js" scheme="http://llmons.top/tags/js/"/>
<category term="算法" scheme="http://llmons.top/tags/%E7%AE%97%E6%B3%95/"/>
</entry>
<entry>
<title>你好,世界</title>
<link href="http://llmons.top/2024/07/16/%E4%BD%A0%E5%A5%BD%EF%BC%8C%E4%B8%96%E7%95%8C/"/>
<id>http://llmons.top/2024/07/16/%E4%BD%A0%E5%A5%BD%EF%BC%8C%E4%B8%96%E7%95%8C/</id>
<published>2024-07-16T06:51:59.000Z</published>
<updated>2024-08-03T15:53:38.000Z</updated>
<content type="html"><![CDATA[<p><del>每回合增加一张牌到你的手牌</del></p><h1 id="h1"><a href="#h1" class="headerlink" title="h1"></a>h1</h1><h2 id="h2"><a href="#h2" class="headerlink" title="h2"></a>h2</h2><h3 id="h3"><a href="#h3" class="headerlink" title="h3"></a>h3</h3><h4 id="h4"><a href="#h4" class="headerlink" title="h4"></a>h4</h4><h5 id="h5"><a href="#h5" class="headerlink" title="h5"></a>h5</h5><h6 id="h6"><a href="#h6" class="headerlink" title="h6"></a>h6</h6><figure class="highlight c"><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></pre></td><td class="code"><pre><span class="line"><span class="comment">// c</span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string"><stdio.h></span></span></span><br><span class="line"></span><br><span class="line"><span class="type">int</span> <span class="title function_">main</span><span class="params">()</span>{</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"Hello World\n"</span>);</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure><figure class="highlight cpp"><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></pre></td><td class="code"><pre><span class="line"><span class="comment">// cpp</span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span><span class="string"><iostream></span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span>{</span><br><span class="line"> std::cout<<<span class="string">"Hello World"</span><<endl;</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure><figure class="highlight java"><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">// java</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">Main</span> {</span><br><span class="line"> <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title function_">main</span><span class="params">(String[] args)</span> {</span><br><span class="line"> System.out.println(<span class="string">"Hello World"</span>);</span><br><span class="line"> }</span><br><span class="line">}</span><br></pre></td></tr></table></figure><figure class="highlight py"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># py</span></span><br><span class="line"><span class="built_in">print</span>(<span class="string">"Hello World"</span>)</span><br></pre></td></tr></table></figure><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// js</span></span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">"Hello World"</span>);</span><br></pre></td></tr></table></figure><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">echo "Hello World";</span><br></pre></td></tr></table></figure><!-- https://i.y.qq.com/n2/m/share/details/taoge.html?id=5775608452 --><!-- <div id="aplayer-MLKpEYew" class="aplayer aplayer-tag-marker meting-tag-marker" data-id="5775608452" data-server="tencent" data-type="playlist" data-mode="circulation" data-autoplay="false" data-mutex="true" data-listmaxheight="340px" data-preload="auto" data-theme="#ad7a86" data-order="random" ></div> --><!-- https://i.y.qq.com/n2/m/share/details/taoge.html?id=9101992810&hosteuin= --><!-- https://music.163.com/#/playlist?id=128871831 -->]]></content>
<summary type="html"><p><del>每回合增加一张牌到你的手牌</del></p>
<h1 id="h1"><a href="#h1" class="headerlink" title="h1"></a>h1</h1><h2 id="h2"><a href="#h2" class="headerli</summary>
</entry>
</feed>