Signing back into the Community for the first time? You'll need to reset your password to access your account.  Find out more.

Forum Discussion

Niels3242's avatar
Niels3242
New Contributor
31 days ago

How to successfully pass 1Password stored SSH key to terminal in VSCode devcontainer?

I have a Rails 8 app which is using devcontainers. On my macOS I have 1Password setup to store my ssh private key and it works as it should from the terminal in the os. Using e.g. ssh commands invokes the authentication prompt from 1password. However, when I am developing the Rails project from the devcontainer attached terminal in VS Code (or in my case Cursor.com, a fork from VS Code), I have the problem, that ssh commands does not invoke 1password prompt. It looks like the whole thing is not really connected as it should. How do I ensure that it works?

My devcontainer config is the standard Rails generates:

// For format details, see https://containers.dev/implementors/json_reference/.
// For config options, see the README at: https://github.com/devcontainers/templates/tree/main/src/ruby
{
"name": "my_app",
"dockerComposeFile": "compose.yaml",
"service": "rails-app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/rails/devcontainer/features/activestorage": {},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/rails/devcontainer/features/postgres-client": {}
},

"containerEnv": {
"CAPYBARA_SERVER_PORT": "45678",
"SELENIUM_HOST": "selenium",
"DB_HOST": "postgres"
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [3000, 5432],

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://containers.dev/implementors/json_reference/#remoteUser.
// "remoteUser": "root",

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "bin/setup --skip-server"
}