<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Remote-Access on Backend Engineering Strategy Tools</title><link>https://backend-engineering-strategy-tools.github.io/site/tags/remote-access/</link><description>Recent content in Remote-Access on Backend Engineering Strategy Tools</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Mon, 01 Jan 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://backend-engineering-strategy-tools.github.io/site/tags/remote-access/index.xml" rel="self" type="application/rss+xml"/><item><title>SSH</title><link>https://backend-engineering-strategy-tools.github.io/site/public-notes/security/ssh/</link><pubDate>Mon, 01 Jan 2024 00:00:00 +0000</pubDate><guid>https://backend-engineering-strategy-tools.github.io/site/public-notes/security/ssh/</guid><description>&lt;p&gt;SSH (Secure Shell) is the standard protocol for encrypted remote access to Linux and Unix systems. It replaced telnet and rsh by wrapping the session in a cryptographic tunnel — authentication, commands, and data transfer all protected against interception and tampering.&lt;/p&gt;
&lt;h2 id="public-key-authentication"&gt;Public key authentication
&lt;/h2&gt;&lt;p&gt;The default auth mechanism for any serious setup. You generate a key pair: a private key that never leaves your machine, and a public key that goes on the remote host.&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-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh-keygen -t ed25519 -C &lt;span style="color:#e6db74"&gt;&amp;#34;your@email.com&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh-copy-id user@host &lt;span style="color:#75715e"&gt;# appends public key to ~/.ssh/authorized_keys on remote&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Prefer &lt;code&gt;ed25519&lt;/code&gt; over the older &lt;code&gt;rsa&lt;/code&gt; — smaller keys, faster, stronger. Keep your private key protected with a passphrase; use &lt;code&gt;ssh-agent&lt;/code&gt; to avoid typing it repeatedly.&lt;/p&gt;
&lt;h2 id="key-deployment-at-scale"&gt;Key deployment at scale
&lt;/h2&gt;&lt;p&gt;When you have many hosts, distributing public keys manually doesn&amp;rsquo;t scale. A typical pattern: submit your public key to a central approval system, which then deploys it to the relevant hosts via automation (Ansible, Puppet, etc.).&lt;/p&gt;
&lt;p&gt;&lt;img alt="SSH key deployment flow" class="gallery-image" data-flex-basis="480px" data-flex-grow="200" height="1280" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://backend-engineering-strategy-tools.github.io/site/public-notes/security/ssh/ssh-deploy-rgm.png" srcset="https://backend-engineering-strategy-tools.github.io/site/public-notes/security/ssh/ssh-deploy-rgm_hu_7067fdd6ddfbd76d.png 800w, https://backend-engineering-strategy-tools.github.io/site/public-notes/security/ssh/ssh-deploy-rgm_hu_a732934bde95612.png 1600w, https://backend-engineering-strategy-tools.github.io/site/public-notes/security/ssh/ssh-deploy-rgm_hu_4339d3dc0eb426e1.png 2400w, https://backend-engineering-strategy-tools.github.io/site/public-notes/security/ssh/ssh-deploy-rgm.png 2560w" width="2560"&gt;&lt;/p&gt;
&lt;p&gt;This keeps a clear audit trail — keys are approved, recorded, and can be revoked centrally without touching individual &lt;code&gt;authorized_keys&lt;/code&gt; files.&lt;/p&gt;
&lt;h2 id="certificate-authentication"&gt;Certificate authentication
&lt;/h2&gt;&lt;p&gt;At larger scale, even centralised key distribution gets unwieldy. SSH certificates solve this properly: instead of deploying individual public keys, you run an SSH Certificate Authority (CA). Hosts and users trust the CA, not each other&amp;rsquo;s individual keys.&lt;/p&gt;
&lt;p&gt;&lt;img alt="SSH certificate authentication architecture" class="gallery-image" data-flex-basis="528px" data-flex-grow="220" height="1018" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://backend-engineering-strategy-tools.github.io/site/public-notes/security/ssh/ssh-certificate-authentication.png" srcset="https://backend-engineering-strategy-tools.github.io/site/public-notes/security/ssh/ssh-certificate-authentication_hu_3c89cbd02831450b.png 800w, https://backend-engineering-strategy-tools.github.io/site/public-notes/security/ssh/ssh-certificate-authentication_hu_98e8f600ea8421b2.png 1600w, https://backend-engineering-strategy-tools.github.io/site/public-notes/security/ssh/ssh-certificate-authentication.png 2242w" width="2242"&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Generate a key pair locally&lt;/li&gt;
&lt;li&gt;Submit the public key to the SSH CA (backed by your identity provider — FreeIPA, Vault, etc.)&lt;/li&gt;
&lt;li&gt;The CA issues a signed certificate with a short TTL&lt;/li&gt;
&lt;li&gt;SSH to any host — the host trusts the CA, so the certificate is accepted without any pre-deployed keys&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Short-lived certificates (hours, not days) dramatically reduce the blast radius of a compromised credential. No revocation lists to maintain.&lt;/p&gt;
&lt;h2 id="ssh-config"&gt;SSH config
&lt;/h2&gt;&lt;p&gt;&lt;code&gt;~/.ssh/config&lt;/code&gt; avoids repetitive flags on every connection:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Host bastion
 HostName bastion.example.com
 User deploy
 IdentityFile ~/.ssh/id_ed25519
 ForwardAgent yes

Host internal-*
 ProxyJump bastion
 User deploy
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;code&gt;ProxyJump&lt;/code&gt; (formerly &lt;code&gt;-J&lt;/code&gt;) lets you reach hosts that aren&amp;rsquo;t directly accessible — you SSH through the bastion transparently.&lt;/p&gt;
&lt;h2 id="port-forwarding"&gt;Port forwarding
&lt;/h2&gt;&lt;p&gt;SSH can tunnel TCP traffic, useful for reaching services on private networks:&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-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Local forward: reach remote Postgres via localhost:5432&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -L 5432:db.internal:5432 bastion
&lt;/span&gt;&lt;/span&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;&lt;span style="color:#75715e"&gt;# Dynamic forward: SOCKS proxy through the bastion&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -D &lt;span style="color:#ae81ff"&gt;1080&lt;/span&gt; bastion
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="hardening-basics"&gt;Hardening basics
&lt;/h2&gt;&lt;p&gt;Key settings in &lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
AllowUsers deploy ansible
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Disable password auth entirely once keys are in place. Restrict which users can log in. Run &lt;code&gt;sshd -t&lt;/code&gt; to validate config before reloading.&lt;/p&gt;
&lt;h2 id="resources"&gt;Resources
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a class="link" href="https://www.openssh.com/manual.html" target="_blank" rel="noopener"
 &gt;OpenSSH manual&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="link" href="https://developer.hashicorp.com/vault/docs/secrets/ssh/signed-ssh-certificates" target="_blank" rel="noopener"
 &gt;SSH certificate authentication (HashiCorp Vault)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="link" href="https://infosec.mozilla.org/guidelines/openssh" target="_blank" rel="noopener"
 &gt;Mozilla SSH Guidelines&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>