<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>escape on foosel.net</title><link>https://foosel.net/tags/escape/</link><description>Recent content in escape on foosel.net</description><generator>Hugo</generator><language>en-us</language><copyright>Gina Häußge (foosel)</copyright><lastBuildDate>Wed, 22 Mar 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://foosel.net/tags/escape/feed.xml" rel="self" type="application/rss+xml"/><item><title>TIL: About SSH escape sequences</title><link>https://foosel.net/til/2023-03-22-about-ssh-escape-sequences/</link><pubDate>Wed, 22 Mar 2023 00:00:00 +0000</pubDate><guid>https://foosel.net/til/2023-03-22-about-ssh-escape-sequences/</guid><description>&lt;p&gt;OpenSSH&amp;rsquo;s &lt;code&gt;ssh&lt;/code&gt; command supports a bunch of escape sequences while a session is running, by default triggered by the &lt;code&gt;~&lt;/code&gt; character. According to &lt;a href="https://linux.die.net/man/1/ssh"&gt;&lt;code&gt;man ssh&lt;/code&gt;&lt;/a&gt; a list of available commands can be requested with &lt;code&gt;~?&lt;/code&gt;. And indeed, hitting &lt;code&gt;~?&lt;/code&gt; within an open SSH session prints some helpful information:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-plain" data-lang="plain"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ ~?
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Supported escape sequences:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ~. - terminate connection (and any multiplexed sessions)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ~B - send a BREAK to the remote system
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ~C - open a command line
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ~R - request rekey
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ~V/v - decrease/increase verbosity (LogLevel)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ~^Z - suspend ssh
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ~# - list forwarded connections
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ~&amp;amp; - background ssh (when waiting for connections to terminate)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ~? - this message
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ~~ - send the escape character by typing it twice
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;(Note that escapes are only recognized immediately after newline.)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I most commonly require &lt;code&gt;~.&lt;/code&gt; to disconnect from a broken SSH session (e.g. something I still had open on my laptop when I sent it to sleep).&lt;/p&gt;</description><content:encoded><![CDATA[<p>OpenSSH&rsquo;s <code>ssh</code> command supports a bunch of escape sequences while a session is running, by default triggered by the <code>~</code> character. According to <a href="https://linux.die.net/man/1/ssh"><code>man ssh</code></a> a list of available commands can be requested with <code>~?</code>. And indeed, hitting <code>~?</code> within an open SSH session prints some helpful information:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-plain" data-lang="plain"><span style="display:flex;"><span>$ ~?
</span></span><span style="display:flex;"><span>Supported escape sequences:
</span></span><span style="display:flex;"><span> ~.   - terminate connection (and any multiplexed sessions)
</span></span><span style="display:flex;"><span> ~B   - send a BREAK to the remote system
</span></span><span style="display:flex;"><span> ~C   - open a command line
</span></span><span style="display:flex;"><span> ~R   - request rekey
</span></span><span style="display:flex;"><span> ~V/v - decrease/increase verbosity (LogLevel)
</span></span><span style="display:flex;"><span> ~^Z  - suspend ssh
</span></span><span style="display:flex;"><span> ~#   - list forwarded connections
</span></span><span style="display:flex;"><span> ~&amp;   - background ssh (when waiting for connections to terminate)
</span></span><span style="display:flex;"><span> ~?   - this message
</span></span><span style="display:flex;"><span> ~~   - send the escape character by typing it twice
</span></span><span style="display:flex;"><span>(Note that escapes are only recognized immediately after newline.)
</span></span></code></pre></div><p>I most commonly require <code>~.</code> to disconnect from a broken SSH session (e.g. something I still had open on my laptop when I sent it to sleep).</p>
<p>The command line opened via <code>~C</code> is quite interesting as well, as it allows configuration of port forwards on the fly, while the session is already running:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-plain" data-lang="plain"><span style="display:flex;"><span>ssh&gt; help
</span></span><span style="display:flex;"><span>Commands:
</span></span><span style="display:flex;"><span>      -L[bind_address:]port:host:hostport    Request local forward
</span></span><span style="display:flex;"><span>      -R[bind_address:]port:host:hostport    Request remote forward
</span></span><span style="display:flex;"><span>      -D[bind_address:]port                  Request dynamic forward
</span></span><span style="display:flex;"><span>      -KL[bind_address:]port                 Cancel local forward
</span></span><span style="display:flex;"><span>      -KR[bind_address:]port                 Cancel remote forward
</span></span><span style="display:flex;"><span>      -KD[bind_address:]port                 Cancel dynamic forward
</span></span></code></pre></div><p>This is once again a &ldquo;TIL&rdquo; that I didn&rsquo;t actually learn about only today, but I keep forgetting about it and then need to frantically google whenever I need it. I hope this way I&rsquo;ll finally remember this stuff 😅</p>
]]></content:encoded></item></channel></rss>