惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
博客园 - 司徒正美
Last Week in AI
Last Week in AI
Recent Announcements
Recent Announcements
Y
Y Combinator Blog
博客园 - 聂微东
M
MIT News - Artificial intelligence
博客园_首页
Jina AI
Jina AI
博客园 - 叶小钗
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
Vercel News
Vercel News
The Cloudflare Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG
N
Netflix TechBlog - Medium
B
Blog
Google DeepMind News
Google DeepMind News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Share .ssh/config with your devcontainer
Theodor Heiselberg · 2026-06-25 · via DEV Community

Theodor Heiselberg

How to share your ~/.ssh/config with devcontainers

The purpose is to enable using git with your provider directly from the devcontainer.

The problem is when running on mac-OS you typically add UseKeychain yes to your config file. Which is a mac specific setting killing your ssh agent.

MacOS - first

Your ~/.ssh folder probably looks something like this:

❯ tree
.
├── config
├── hetzner_id_ed25519
├── hetzner_id_ed25519.pub
├── known_hosts
├── known_hosts.old
├── README.md
├── sukkerfrit.github
├── sukkerfrit.github.pub
└── test.sh

And the content of your config something like this:

Host tahh
    HostName github.com
    User git
    AddKeysToAgent yes
    IdentityFile ~/.ssh/sukkerfrit.github
    IdentitiesOnly yes
    ForwardAgent yes

Host hetzner-ktk-test
    HostName xx.xx.xx.xx
    User root
    AddKeysToAgent yes
    UseKeychain yes
    IdentityFile ~/.ssh/hetzner_id_ed25519

UseKeychain
Is a mac-OS specific SSH setting. We use it to save and fetch the SSH-key passphrase automatically.

BUT it doesn't work on Linux and will actually course an exception on load rendering using eg. git directly from your devcontainer impossible.

This image is just working on root which i normally never do. I use to create a container-user in my container - I guess I was just lazy today.

This is way I share my ~/.ssh/config with devcontainers.

1. Add host's ~/.ssh to docker as mount

My 'trick' is to just mount my host's .ssh folder as read only - but to eg. /root/.sshtemplate.

Then you don't end up editing your host's config.

devcontainer.json

{
  "name": "some-funkey-name",
  "dockerComposeFile": "docker-compose.yml",
  "service": "development",
  "workspaceFolder": "/xyz",
  "postCreateCommand": "./.devcontainer/post-container-install.sh",
  "mounts": [
    "source=${localEnv:HOME}/.ssh,target=/root/.sshtemplate,type=bind,readonly,consistency=cached"
  ],

Change the target if you work on a different user.

2. Copy from .sshtemplate -> .ssh

copy-ssh-files.sh

#!/usr/bin/env bash
set -u

if [ -d /root/.sshtemplate ]; then
  cp -rf /root/.sshtemplate/. ~/.ssh/
  chmod 700 ~/.ssh
  chmod 600 ~/.ssh/* 2>/dev/null || true
fi

3. Remove lines with UseKeychain

remove-usekeychain-lines.sh

#!/usr/bin/env bash
set -u

# Remove UseKeychain (case-insensitive) from a config file if it exists
if [ -f "$1" ]; then
  sed -i '/UseKeychain/I d' "$1"
  echo "UseKeychain removed from $1."
fi

4. Create post install file

post-container-install.sh

#!/usr/bin/env bash
...
"$SCRIPTS_DIR/copy-ssh-files.sh"
"$SCRIPTS_DIR/remove-usekeychain-lines.sh" ~/.ssh/config

Enjoy!