<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>svnscha - ssh</title>
    <subtitle>automating annoying tasks, sharing tips, and embracing less frustration</subtitle>
    <link rel="self" type="application/atom+xml" href="https://svnscha.de/tags/ssh/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://svnscha.de"/>
    <generator uri="https://astro.build/">Astro</generator>
    <updated>2025-10-10T00:00:00+00:00</updated>
    <id>https://svnscha.de/tags/ssh/atom.xml</id>
    <entry xml:lang="en">
        <title>How to: Use Docker Remote Contexts with SSH</title>
        <published>2025-10-10T00:00:00+00:00</published>
        <updated>2025-10-10T00:00:00+00:00</updated>
        <author>
          <name>Sven Scharmentke</name>
        </author>
        <link rel="alternate" type="text/html" href="https://svnscha.de/posts/docker-remote-context/"/>
        <id>https://svnscha.de/posts/docker-remote-context/</id>
        <summary type="html">A simple and secure guide to configuring SSH-based Docker remote contexts for offloading resource-intensive Docker operations to a remote host while keeping your local environment lightweight.</summary>
        <content type="html" xml:base="https://svnscha.de/posts/docker-remote-context/">&lt;h2 id=&quot;the-problem-when-your-laptop-becomes-a-jet-engine&quot;&gt;The Problem: When Your Laptop Becomes a Jet Engine&lt;/h2&gt;
&lt;p&gt;Working on resource-intensive Docker projects often turns laptops into jet engines. The fans spin up, the CPU overheats, and performance degrades significantly. This is especially problematic when working with limited resources - lightweight laptops, VDI sessions, or simply wanting to preserve your hardware.&lt;/p&gt;
&lt;p&gt;An SSH-based Docker context keeps the development tools on your local machine while running Docker workloads on a more capable remote host. Your laptop stays responsive and the remote system handles the heavier work.&lt;/p&gt;
&lt;h2 id=&quot;step-1-prerequisites&quot;&gt;Step 1: Prerequisites&lt;/h2&gt;
&lt;p&gt;Before we start, ensure you have:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;SSH access configured&lt;/strong&gt; to your remote Docker host with a proper SSH config entry like:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# ~/.ssh/config&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Host docker-remote&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  HostName 10.10.10.10&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  IdentityFile ~/.ssh/id_rsa&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  User ubuntu&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;&lt;strong&gt;Your user is in the docker group&lt;/strong&gt; on the remote host:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; usermod&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; -aG&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; docker&lt;/span&gt;&lt;span style=&quot;color:#9CDCFE&quot;&gt; $USER&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That's all the setup needed! Now let's create the Docker context.&lt;/p&gt;
&lt;h2 id=&quot;step-2-create-the-ssh-based-docker-context&quot;&gt;Step 2: Create the SSH-Based Docker Context&lt;/h2&gt;
&lt;p&gt;Creating the Docker context is incredibly simple when you have SSH properly configured.&lt;/p&gt;
&lt;h3 id=&quot;create-your-ssh-based-remote-context&quot;&gt;Create Your SSH-Based Remote Context&lt;/h3&gt;
&lt;p&gt;Create a new context using your SSH config host:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;docker&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; context&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; create&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; docker-remote&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; --docker&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; host=ssh://docker-remote&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That's it! Docker will use your existing SSH configuration, including the hostname, user, and identity file you've already set up.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The beauty of this approach:&lt;/strong&gt; No daemon.json changes, no TCP configuration, no port forwarding, no firewall rules, no TLS certificate generation - just leverage your existing SSH security infrastructure. Simple and elegant!&lt;/p&gt;
&lt;h3 id=&quot;check-your-current-contexts&quot;&gt;Check Your Current Contexts&lt;/h3&gt;
&lt;p&gt;First, let's see what contexts you currently have:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;docker&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; context&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; ls&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You'll probably see something like:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;NAME              DESCRIPTION                               DOCKER ENDPOINT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;default *         Current DOCKER_HOST based configuration   npipe:////./pipe/docker_engine&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;desktop-linux     Docker Desktop                            npipe:////./pipe/dockerDesktopLinuxEngine&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;desktop-windows   Docker Desktop                            npipe:////./pipe/dockerDesktopWindowsEngine&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;docker-remote                                               ssh://docker-remote&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;test-the-connection&quot;&gt;Test the Connection&lt;/h3&gt;
&lt;p&gt;Let's verify everything works:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;docker&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; --context&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; docker-remote&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; container&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; ls&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you see your remote containers listed (or an empty list if none are running), congratulations! You're successfully connected to your remote Docker host via SSH.&lt;/p&gt;
&lt;h2 id=&quot;step-3-make-it-your-default-optional&quot;&gt;Step 3: Make It Your Default (Optional)&lt;/h2&gt;
&lt;p&gt;If you want to use the remote context by default, you can switch to it:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;docker&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; context&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; use&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; docker-remote&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now all your &lt;code&gt;docker&lt;/code&gt; commands will automatically use the remote host:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;docker&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; container&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; ls&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# This now runs on your remote host!&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;environment-variable-override&quot;&gt;Environment Variable Override&lt;/h3&gt;
&lt;p&gt;For more granular control, you can also use the &lt;code&gt;DOCKER_CONTEXT&lt;/code&gt; environment variable:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# Windows PowerShell&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9CDCFE&quot;&gt;$env&lt;/span&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;:DOCKER_CONTEXT = &lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt;&quot;docker-remote&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# Linux/macOS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#569CD6&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color:#9CDCFE&quot;&gt; DOCKER_CONTEXT&lt;/span&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#9CDCFE&quot;&gt;docker-remote&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This approach is particularly useful in CI/CD scenarios or when you want different shells to use different contexts.&lt;/p&gt;
&lt;h2 id=&quot;why-ssh-is-better&quot;&gt;Why SSH is Better&lt;/h2&gt;
&lt;p&gt;Using SSH for Docker remote contexts offers several advantages over TCP:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Security&lt;/strong&gt;: All communication is encrypted by default&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Authentication&lt;/strong&gt;: Leverages existing SSH keys and authentication methods&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No daemon configuration&lt;/strong&gt;: No need to modify Docker daemon settings on the remote host&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Firewall friendly&lt;/strong&gt;: Uses standard SSH port (22)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Audit trail&lt;/strong&gt;: SSH logging provides better security monitoring&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;switching-between-contexts&quot;&gt;Switching Between Contexts&lt;/h2&gt;
&lt;p&gt;Need to switch back to local Docker for something? Easy:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# List available contexts&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;docker&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; context&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; ls&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# Switch to local Docker&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;docker&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; context&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; use&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; default&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# Or use a specific context for one command&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;docker&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; --context&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; default&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; container&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; ls&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;bonus-powershell-function-for-quick-context-switching&quot;&gt;Bonus: PowerShell Function for Quick Context Switching&lt;/h2&gt;
&lt;p&gt;Here's a handy PowerShell function to make switching contexts even easier. Add this to your PowerShell profile for instant remote Docker activation:&lt;/p&gt;
&lt;h3 id=&quot;edit-your-powershell-profile&quot;&gt;Edit Your PowerShell Profile&lt;/h3&gt;
&lt;p&gt;First, open your PowerShell profile for editing:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;powershell&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;notepad &lt;/span&gt;&lt;span style=&quot;color:#9CDCFE&quot;&gt;$PROFILE&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If the file doesn't exist yet, PowerShell will ask if you want to create it - say yes.&lt;/p&gt;
&lt;h3 id=&quot;add-the-function&quot;&gt;Add the Function&lt;/h3&gt;
&lt;p&gt;Add this function to your profile:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;powershell&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#569CD6&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt; docker-remote-activate&lt;/span&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#9CDCFE&quot;&gt;    $env:DOCKER_CONTEXT&lt;/span&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt;&quot;docker-remote&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;    Write-Host&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; &quot;Docker context switched to remote host&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Replace &lt;code&gt;&quot;docker-remote&quot;&lt;/code&gt; with whatever you named your remote context.&lt;/p&gt;
&lt;h3 id=&quot;save-and-reload&quot;&gt;Save and Reload&lt;/h3&gt;
&lt;p&gt;Save the file and reload your PowerShell profile:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;powershell&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color:#9CDCFE&quot;&gt;$PROFILE&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;usage&quot;&gt;Usage&lt;/h3&gt;
&lt;p&gt;Now you can instantly activate remote Docker in any PowerShell session:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;powershell&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# Activate remote Docker for this session only&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;docker-remote-activate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# Now all Docker commands run remotely&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;docker ps&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;docker images&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;docker build .&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The beauty of this approach is that it only affects the current PowerShell session - open a new terminal window and you're back to local Docker by default!&lt;/p&gt;
&lt;h3 id=&quot;global-vs-terminal-specific-context-switching&quot;&gt;Global vs Terminal-Specific Context Switching&lt;/h3&gt;
&lt;p&gt;You have two ways to switch between local and remote Docker contexts:&lt;/p&gt;
&lt;h4 id=&quot;global-context-switching&quot;&gt;Global Context Switching&lt;/h4&gt;
&lt;p&gt;Affects all terminals system-wide:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# Switch globally to remote&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;docker&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; context&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; use&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; docker-remote&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# Switch back to local&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;docker&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; context&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; use&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; default&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;terminal-specific-context&quot;&gt;Terminal-Specific Context&lt;/h4&gt;
&lt;p&gt;Affects only the current terminal session:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;powershell&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# Terminal 1: Remote context&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;docker-remote-activate&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;docker ps  &lt;/span&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# runs remotely&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# Terminal 2: Still local context  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;docker ps  &lt;/span&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# runs locally&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Whether you prefer global context switching or terminal-specific control, Docker remote contexts give you the flexibility to work exactly how you want.&lt;/p&gt;
&lt;h2 id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;
&lt;p&gt;Using SSH-based Docker remote contexts provides a secure, simple solution for offloading resource-intensive Docker operations to remote hosts. With just a single command and proper SSH configuration, you can transform your development workflow without compromising security.&lt;/p&gt;
&lt;p&gt;The SSH approach eliminates the complexity of daemon configuration while providing enterprise-grade security through encrypted communication and existing authentication infrastructure.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Key Benefits:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Secure by default (encrypted communication)&lt;/li&gt;
&lt;li&gt;No daemon configuration required&lt;/li&gt;
&lt;li&gt;Uses standard SSH authentication&lt;/li&gt;
&lt;li&gt;Works with existing SSH infrastructure&lt;/li&gt;
&lt;li&gt;Simple one-command setup&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;References:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.docker.com/engine/manage-resources/contexts/&quot;&gt;Docker Context Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.docker.com/engine/context/remote/&quot;&gt;Docker SSH Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.ssh.com/academy/ssh/public-key-authentication&quot;&gt;SSH Key Authentication&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
    </entry>
    <entry xml:lang="en">
        <title>Windows: Install integrated OpenSSH Server</title>
        <published>2025-04-03T00:00:00+00:00</published>
        <updated>2025-04-03T00:00:00+00:00</updated>
        <author>
          <name>Sven Scharmentke</name>
        </author>
        <link rel="alternate" type="text/html" href="https://svnscha.de/posts/windows-openssh-server/"/>
        <id>https://svnscha.de/posts/windows-openssh-server/</id>
        <summary type="html">Enable built-in OpenSSH server on Windows for remote access and VSCode Remote development</summary>
        <content type="html" xml:base="https://svnscha.de/posts/windows-openssh-server/">&lt;p&gt;Tired of everyone SSHing into Linux? Flip the script: SSH into Windows from your Linux box. Works great with VSCode Remote too. Here's how to enable the built-in OpenSSH server on Windows.&lt;/p&gt;
&lt;h3 id=&quot;step-1-check-installed-openssh-components&quot;&gt;Step 1: Check Installed OpenSSH Components&lt;/h3&gt;
&lt;p&gt;First, open a PowerShell window with administrator privileges. Let's see what's already installed:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;Get-WindowsCapability&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; -Online&lt;/span&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt; | &lt;/span&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;Where-Object&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; Name&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; -like&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; 'OpenSSH*'&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You might see output indicating that the client is installed but not the server:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Name  : OpenSSH.Client~~~~0.0.1.0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;State : Installed&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Name  : OpenSSH.Server~~~~0.0.1.0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;State : NotPresent&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;step-2-install-the-openssh-server&quot;&gt;Step 2: Install the OpenSSH Server&lt;/h3&gt;
&lt;p&gt;If the server isn't present, let's bring it on board. Run:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;Add-WindowsCapability&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; -Online&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; -Name&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; OpenSSH.Server~~~~0.0.1.0&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;step-3-start-and-enable-the-ssh-server&quot;&gt;Step 3: Start and Enable the SSH Server&lt;/h3&gt;
&lt;p&gt;Now, let's get the &lt;code&gt;sshd&lt;/code&gt; service up and running:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;Start-Service&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; sshd&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And ensure it starts automatically with Windows:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;Set-Service&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; -Name&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; sshd&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; -StartupType&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; 'Automatic'&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That's it.&lt;/p&gt;
</content>
    </entry>
    <entry xml:lang="en">
        <title>Simplify SSH</title>
        <published>2024-10-03T00:00:00+00:00</published>
        <updated>2024-10-03T00:00:00+00:00</updated>
        <author>
          <name>Sven Scharmentke</name>
        </author>
        <link rel="alternate" type="text/html" href="https://svnscha.de/posts/simplify-ssh/"/>
        <id>https://svnscha.de/posts/simplify-ssh/</id>
        <summary type="html">How to stop typing your SSH Key passphrase every time. (because, let's be real, we're all a little lazy)</summary>
        <content type="html" xml:base="https://svnscha.de/posts/simplify-ssh/">&lt;h2 id=&quot;why-you-ask&quot;&gt;Why, You Ask?&lt;/h2&gt;
&lt;p&gt;I was tired of entering my SSH key passphrase every time I connected to a server. The setup below lets &lt;code&gt;ssh-agent&lt;/code&gt; remember it for the current terminal session and also keeps host settings in one place.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;It's time-consuming and frustrating. I'm tired of it.&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;getting-started&quot;&gt;Getting Started&lt;/h2&gt;
&lt;p&gt;So, you've got your shiny new SSH key and every time you want to connect to a server, you're greeted with that ever-familiar password prompt. Sure, typing your SSH key passphrase every time is good for security, but, come on  -  who wants to do that? I mean, I don't know about you, but I've got enough passwords to remember without constantly dealing with this nonsense.&lt;/p&gt;
&lt;p&gt;Let's save ourselves some time and effort by getting the SSH agent to remember our keys for us. That way, you can just run your commands like the seasoned developer you are without worrying about the whole &quot;password entering&quot; thing every single time.&lt;/p&gt;
&lt;h2 id=&quot;step-1-start-the-ssh-agent&quot;&gt;Step 1: Start the SSH Agent&lt;/h2&gt;
&lt;p&gt;First things first  -  let's get the SSH agent up and running. It's like your personal SSH butler, here to remember your key so you don't have to.&lt;/p&gt;
&lt;p&gt;Open up your terminal and type:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;eval&lt;/span&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt; $(&lt;/span&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;ssh-agent&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; -s&lt;/span&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Boom! Now the agent is running in the background, ready to hold your keys like the responsible little daemon it is.&lt;/p&gt;
&lt;h2 id=&quot;step-2-add-your-key-to-the-ssh-agent&quot;&gt;Step 2: Add your key to the SSH Agent&lt;/h2&gt;
&lt;p&gt;Now that the agent is up, let's give it your key. You only need to do this once per session, and the agent will keep it ready for you.&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;ssh-add&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; ~/.ssh/your_key&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Replace &lt;code&gt;your_key&lt;/code&gt; with the name of your private key file. Enter the passphrase once and &lt;code&gt;ssh-agent&lt;/code&gt; will remember it for the rest of the terminal session.&lt;/p&gt;
&lt;h2 id=&quot;step-3-configure-your-ssh-setup-to-be-even-lazier-i-mean-efficient&quot;&gt;Step 3: Configure your SSH setup to be even lazier (I mean efficient)&lt;/h2&gt;
&lt;p&gt;Okay, we've got the agent running and the key added, but we can take it one step further. Why not tell SSH exactly what key to use for which server, so you never have to worry about it picking the wrong one?&lt;/p&gt;
&lt;p&gt;To do this, we're going to set up a &lt;code&gt;~/.ssh/config&lt;/code&gt; file. If you don't have this file yet, don't worry  -  it's as easy as creating it:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;touch&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; ~/.ssh/config&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, crack open that file with your favorite text editor and set things up like this:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;Host&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; your-server-alias&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;    HostName&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; your.server.com&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;    User&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; your-username&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;    IdentityFile&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; ~/.ssh/your_key&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;    IdentitiesOnly&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; yes&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;breaking-it-down&quot;&gt;Breaking it down&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Host&lt;/strong&gt;: You can use any alias here that makes sense to you. This is what you'll type when you want to connect to this server.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;HostName&lt;/strong&gt;: The actual domain or IP address of the server.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;User&lt;/strong&gt;: Your username on that server, so you do not have to specify it each time.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IdentityFile&lt;/strong&gt;: The path to your SSH private key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IdentitiesOnly yes&lt;/strong&gt;: Tells SSH to use &lt;em&gt;only&lt;/em&gt; this key, rather than trying every key it can find in the agent (which is how you avoid that annoying &quot;user mismatch&quot; issue).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;step-4-create-a-wrapper-script-for-ssh-agent-control&quot;&gt;Step 4: Create a wrapper script for SSH Agent control&lt;/h2&gt;
&lt;p&gt;Alright, you want control over when your SSH agent starts up  -  totally understandable! Instead of running the agent automatically on login (which might feel a bit &lt;em&gt;too&lt;/em&gt; autonomous), we'll create a neat little wrapper script. You can trigger it whenever you feel like starting the agent and adding your SSH key for the session.&lt;/p&gt;
&lt;p&gt;Here's how to set that up.&lt;/p&gt;
&lt;h3 id=&quot;create-the-wrapper-script&quot;&gt;Create the wrapper script&lt;/h3&gt;
&lt;p&gt;Let's create a script that starts the SSH agent, adds your key, and gives you control over when it runs. We'll call this script &lt;code&gt;init-ssh&lt;/code&gt;, and we'll stick it somewhere like &lt;code&gt;/usr/local/bin&lt;/code&gt; so it's available from anywhere in your terminal.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create the script:&lt;/strong&gt;
Open your terminal and create the &lt;code&gt;init-ssh&lt;/code&gt; script:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; nano&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; /usr/local/bin/init-ssh&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Add the script content:&lt;/strong&gt;
Paste the following content into the file:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;#!/bin/bash&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# Start the SSH agent&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;eval&lt;/span&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt; $(&lt;/span&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;ssh-agent&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; -s&lt;/span&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# Add the key to the agent&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;ssh-add&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; ~/.ssh/your_key&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# Optional: Display agent status for peace of mind&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;ssh-add&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; -l&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Make the script executable:&lt;/strong&gt;
Give the script executable permissions:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; chmod&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; +x&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; /usr/local/bin/init-ssh&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&quot;how-to-use-the-script&quot;&gt;How to use the script&lt;/h4&gt;
&lt;p&gt;Whenever you want to start your SSH agent for a session, just run:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; init-ssh&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will start the agent, add your key, and show you a list of the keys currently loaded in the agent. You've got full control  -  start the agent when you want, stop it when you're done, and enjoy a password-free SSH experience for the duration of that session.&lt;/p&gt;
&lt;h3 id=&quot;optional-stopping-the-ssh-agent&quot;&gt;Optional: Stopping the SSH Agent&lt;/h3&gt;
&lt;p&gt;If you want to stop the SSH agent after you're done with it, you can either let it die when you close your terminal or manually kill it with:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;eval&lt;/span&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt; $(&lt;/span&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;ssh-agent&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; -k&lt;/span&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That way, you get all the convenience of an SSH agent when you need it, without it running indefinitely in the background. You're now in complete control of your SSH setup, and you can keep things secure and efficient, exactly the way you like it.&lt;/p&gt;
&lt;p&gt;Happy SSH'ing!&lt;/p&gt;
</content>
    </entry>
</feed>
