Anyspheres Dev Container Extension: Use the Name Property of DevContainers + Allow to Switch Containers

Yes, I’m experiencing the same thing as @Wet_Rain.

Another thing I noticed is that it now copies .gitconfig from the host, which it didn’t do before.

@ravirahman

From outside of devcontainer

➜ echo $SSH_AUTH_SOCK
/private/tmp/com.apple.launchd.A2fnVCeoKa/Listeners
➜ ssh-add -L
ssh-ed25519 ....

From inside devcontainer

➜ ssh-add -L
Could not open a connection to your authentication agent.

Log output

Forwarding SSH agent /private/tmp/com.apple.launchd.A2fnVCeoKa/Listeners socket
2025-07-10 22:56:16.317 [info] Spawned process 22923: 'docker' 'exec' '-u' 'root' '-i' '659f5f2dc7fecd894d56898d8a627de8b1a3ebb00f9f4347246db427c3058d2b' 'bash' '-c' '/root/.cursor-server/bin/acbbbeba64d24c74c0ea638295aad36ebf9f4220/node -e "
const net = require('net');
const fs = require('fs');
process.stdin.pause();
const server = net.createServer(function (socket) {
console.error('Connection established');
socket.pipe(process.stdout);
process.stdin.pipe(socket);
});
server.listen({ path: '/tmp/cursor-remote-ssh-cd24ef8d-1c96-4959-bc7a-078abf1e73bd.sock'});
server.on('close', function (hadError) {
console.error(hadError ? 'Remote close with error' : 'Remote close');
process.exit(hadError ? 1 : 0);
});
server.on('error', function (err) {
process.stderr.write(err && (err.stack || err.message) || String(err));
});
process.stdin.on('close', function (hadError) {
console.error(hadError ? 'Remote stdin close with error' : 'Remote stdin close');
process.exit(hadError ? 1 : 0);
});
process.on('uncaughtException', function (err) {
fs.writeSync(process.stderr.fd, 'error: ' + (err.stack || err.message) + '\n');
process.exit(1);
});
"'
2025-07-10 22:56:16.318 [info] [ssh_auth_socket][/tmp/cursor-remote-ssh-cd24ef8d-1c96-4959-bc7a-078abf1e73bd.sock] created socket server in container and bound forwarder to it
2025-07-10 22:56:16.318 [info] Forwarding exec server locally via tcpForward method
2025-07-10 22:56:16.318 [info] Forwarding 127.0.0.1:33839 to 127.0.0.1:0 for container 659f5f2dc7fecd894d56898d8a627de8b1a3ebb00f9f4347246db427c3058d2b
2025-07-10 22:56:16.318 [info] Spawned process 22924: '/Applications/Cursor.app/Contents/Frameworks/Cursor Helper (Plugin).app/Contents/MacOS/Cursor Helper (Plugin)' '/Users/jacob/.cursor/extensions/anysphere.remote-containers-1.0.11/dist/scripts/forwarder.js' 'port' '659f5f2dc7fecd894d56898d8a627de8b1a3ebb00f9f4347246db427c3058d2b' '/root/.cursor-server/bin/acbbbeba64d24c74c0ea638295aad36ebf9f4220/node' 'root' '127.0.0.1:0' '127.0.0.1:33839'
2025-07-10 22:56:16.378 [info] forwarderProcess stdout: forwarder: Forwarding (remote) 127.0.0.1:33839 to (local) 127.0.0.1:0 for container 659f5f2dc7fecd894d56898d8a627de8b1a3ebb00f9f4347246db427c3058d2b

2025-07-10 22:56:16.380 [info] forwarderProcess stdout: forwarder: ====forwarderPort=64490====

2025-07-10 22:56:16.380 [info] Found forwarder port: 64490
2025-07-10 22:56:16.380 [info] [tcpForward][(remote) 127.0.0.1:64490 -> (local) 127.0.0.1:64490] Starting no-op local tunnel
2025-07-10 22:56:17.480 [info] Forwarding 127.0.0.1:9443 to 127.0.0.1:9443 for container 659f5f2dc7fecd894d56898d8a627de8b1a3ebb00f9f4347246db427c3058d2b
2025-07-10 22:56:17.480 [info] Spawned process 22939: '/Applications/Cursor.app/Contents/Frameworks/Cursor Helper (Plugin).app/Contents/MacOS/Cursor Helper (Plugin)' '/Users/jacob/.cursor/extensions/anysphere.remote-containers-1.0.11/dist/scripts/forwarder.js' 'port' '659f5f2dc7fecd894d56898d8a627de8b1a3ebb00f9f4347246db427c3058d2b' '/root/.cursor-server/bin/acbbbeba64d24c74c0ea638295aad36ebf9f4220/node' 'root' '127.0.0.1:9443' '127.0.0.1:9443'
2025-07-10 22:56:17.542 [info] forwarderProcess stdout: forwarder: Forwarding (remote) 127.0.0.1:9443 to (local) 127.0.0.1:9443 for container 659f5f2dc7fecd894d56898d8a627de8b1a3ebb00f9f4347246db427c3058d2b

2025-07-10 22:56:17.544 [info] forwarderProcess stdout: forwarder: ====forwarderPort=9443====

2025-07-10 22:56:17.544 [info] Found forwarder port: 9443
2025-07-10 22:56:17.544 [info] [tcpForward][(remote) 127.0.0.1:9443 -> (local) 127.0.0.1:9443] Starting no-op local tunnel
2025-07-10 22:56:17.545 [info] Forwarding 127.0.0.1:8080 to 127.0.0.1:8080 for container 659f5f2dc7fecd894d56898d8a627de8b1a3ebb00f9f4347246db427c3058d2b
2025-07-10 22:56:17.546 [info] Spawned process 22944: '/Applications/Cursor.app/Contents/Frameworks/Cursor Helper (Plugin).app/Contents/MacOS/Cursor Helper (Plugin)' '/Users/jacob/.cursor/extensions/anysphere.remote-containers-1.0.11/dist/scripts/forwarder.js' 'port' '659f5f2dc7fecd894d56898d8a627de8b1a3ebb00f9f4347246db427c3058d2b' '/root/.cursor-server/bin/acbbbeba64d24c74c0ea638295aad36ebf9f4220/node' 'root' '127.0.0.1:8080' '127.0.0.1:8080'
2025-07-10 22:56:17.632 [info] forwarderProcess stdout: forwarder: Forwarding (remote) 127.0.0.1:8080 to (local) 127.0.0.1:8080 for container 659f5f2dc7fecd894d56898d8a627de8b1a3ebb00f9f4347246db427c3058d2b

2025-07-10 22:56:17.633 [info] forwarderProcess stdout: forwarder: ====forwarderPort=8080====

2025-07-10 22:56:17.633 [info] Found forwarder port: 8080
2025-07-10 22:56:17.633 [info] [tcpForward][(remote) 127.0.0.1:8080 -> (local) 127.0.0.1:8080] Starting no-op local tunnel

IMO, you need to mount SSH_AUTH_SOCK into your devcontainer. @tl-jacob

Remember to disable SSHAgentForward in the devcontainer extension settings.

@ravirahman looks like the process that is supposed to forward the agent is continuously failing

2025-07-13 22:47:31.742 [info] Registering label formatter for dev-container*
2025-07-13 22:47:31.750 [info] [server install]: exit
2025-07-13 22:47:31.757 [info] Forwarding SSH agent /private/tmp/com.apple.launchd.A2fnVCeoKa/Listeners socket
2025-07-13 22:47:31.758 [info] [ssh_auth_socket][/tmp/cursor-remote-ssh-82fa5941-aca5-4afc-8e8f-09bb1bbb9a85.sock] Creating symlink /tmp/cursor-remote-ssh-94f05fed-4828-49c5-b508-8a519b80e240.sock -> /tmp/cursor-remote-ssh-82fa5941-aca5-4afc-8e8f-09bb1bbb9a85.sock
2025-07-13 22:47:31.758 [info] Spawned process 23607: 'docker' 'exec' '-u' 'root' 'a91663563f2f5d5ba7cf990bcbef56a2bc44e1d3684d719e63a67aa47d6f55f1' 'ln' '-sf' '/tmp/cursor-remote-ssh-82fa5941-aca5-4afc-8e8f-09bb1bbb9a85.sock' '/tmp/cursor-remote-ssh-94f05fed-4828-49c5-b508-8a519b80e240.sock'
2025-07-13 22:47:31.758 [info] [symlink ssh_auth_sock]: Running command: docker
2025-07-13 22:47:31.817 [info] [symlink ssh_auth_sock]: Command completed with exit code 0
2025-07-13 22:47:31.817 [info] Spawned process 23611: 'docker' 'exec' '-u' 'root' '-i' 'a91663563f2f5d5ba7cf990bcbef56a2bc44e1d3684d719e63a67aa47d6f55f1' 'bash' '-c' '/root/.cursor-server/bin/a8e95743c5268be73767c46944a71f4465d05c90/node -e "
const net = require('net');
const fs = require('fs');
process.stdin.pause();
const server = net.createServer(function (socket) {
console.error('Connection established');
socket.pipe(process.stdout);
process.stdin.pipe(socket);
});
server.listen({ path: '/tmp/cursor-remote-ssh-82fa5941-aca5-4afc-8e8f-09bb1bbb9a85.sock'});
server.on('close', function (hadError) {
console.error(hadError ? 'Remote close with error' : 'Remote close');
process.exit(hadError ? 1 : 0);
});
server.on('error', function (err) {
process.stderr.write(err && (err.stack || err.message) || String(err));
});
process.stdin.on('close', function (hadError) {
console.error(hadError ? 'Remote stdin close with error' : 'Remote stdin close');
process.exit(hadError ? 1 : 0);
});
process.on('uncaughtException', function (err) {
fs.writeSync(process.stderr.fd, 'error: ' + (err.stack || err.message) + '\n');
process.exit(1);
});
"'
2025-07-13 22:47:31.817 [info] [ssh_auth_socket][/tmp/cursor-remote-ssh-82fa5941-aca5-4afc-8e8f-09bb1bbb9a85.sock] created socket server in container and bound forwarder to it
2025-07-13 22:47:31.818 [info] Forwarding exec server locally via tcpForward method
2025-07-13 22:47:31.818 [info] Forwarding 127.0.0.1:35607 to 127.0.0.1:0 for container a91663563f2f5d5ba7cf990bcbef56a2bc44e1d3684d719e63a67aa47d6f55f1
2025-07-13 22:47:31.818 [info] Spawned process 23612: '/Applications/Cursor.app/Contents/Frameworks/Cursor Helper (Plugin).app/Contents/MacOS/Cursor Helper (Plugin)' '/Users/jacob/.cursor/extensions/anysphere.remote-containers-1.0.13/dist/scripts/forwarder.js' 'port' 'a91663563f2f5d5ba7cf990bcbef56a2bc44e1d3684d719e63a67aa47d6f55f1' '/root/.cursor-server/bin/a8e95743c5268be73767c46944a71f4465d05c90/node' 'root' '127.0.0.1:0' '127.0.0.1:35607'
2025-07-13 22:47:31.887 [info] forwarderProcess stdout: forwarder: Forwarding (remote) 127.0.0.1:35607 to (local) 127.0.0.1:0 for container a91663563f2f5d5ba7cf990bcbef56a2bc44e1d3684d719e63a67aa47d6f55f1

2025-07-13 22:47:31.889 [info] forwarderProcess stdout: forwarder: ====forwarderPort=51237====

2025-07-13 22:47:31.889 [info] Found forwarder port: 51237
2025-07-13 22:47:31.889 [info] [tcpForward][(remote) 127.0.0.1:51237 -> (local) 127.0.0.1:51237] Starting no-op local tunnel
2025-07-13 22:47:33.227 [info] Forwarding 127.0.0.1:9443 to 127.0.0.1:9443 for container a91663563f2f5d5ba7cf990bcbef56a2bc44e1d3684d719e63a67aa47d6f55f1
2025-07-13 22:47:33.227 [info] Spawned process 23632: '/Applications/Cursor.app/Contents/Frameworks/Cursor Helper (Plugin).app/Contents/MacOS/Cursor Helper (Plugin)' '/Users/jacob/.cursor/extensions/anysphere.remote-containers-1.0.13/dist/scripts/forwarder.js' 'port' 'a91663563f2f5d5ba7cf990bcbef56a2bc44e1d3684d719e63a67aa47d6f55f1' '/root/.cursor-server/bin/a8e95743c5268be73767c46944a71f4465d05c90/node' 'root' '127.0.0.1:9443' '127.0.0.1:9443'
2025-07-13 22:47:33.292 [info] forwarderProcess stdout: forwarder: Forwarding (remote) 127.0.0.1:9443 to (local) 127.0.0.1:9443 for container a91663563f2f5d5ba7cf990bcbef56a2bc44e1d3684d719e63a67aa47d6f55f1

2025-07-13 22:47:33.294 [info] forwarderProcess stdout: forwarder: ====forwarderPort=9443====

2025-07-13 22:47:33.295 [info] Found forwarder port: 9443
2025-07-13 22:47:33.295 [info] [tcpForward][(remote) 127.0.0.1:9443 -> (local) 127.0.0.1:9443] Starting no-op local tunnel
2025-07-13 22:47:33.296 [info] Forwarding 127.0.0.1:8080 to 127.0.0.1:8080 for container a91663563f2f5d5ba7cf990bcbef56a2bc44e1d3684d719e63a67aa47d6f55f1
2025-07-13 22:47:33.297 [info] Spawned process 23637: '/Applications/Cursor.app/Contents/Frameworks/Cursor Helper (Plugin).app/Contents/MacOS/Cursor Helper (Plugin)' '/Users/jacob/.cursor/extensions/anysphere.remote-containers-1.0.13/dist/scripts/forwarder.js' 'port' 'a91663563f2f5d5ba7cf990bcbef56a2bc44e1d3684d719e63a67aa47d6f55f1' '/root/.cursor-server/bin/a8e95743c5268be73767c46944a71f4465d05c90/node' 'root' '127.0.0.1:8080' '127.0.0.1:8080'
2025-07-13 22:47:33.373 [info] forwarderProcess stdout: forwarder: Forwarding (remote) 127.0.0.1:8080 to (local) 127.0.0.1:8080 for container a91663563f2f5d5ba7cf990bcbef56a2bc44e1d3684d719e63a67aa47d6f55f1

2025-07-13 22:47:33.375 [info] forwarderProcess stdout: forwarder: ====forwarderPort=8080====

2025-07-13 22:47:33.375 [info] Found forwarder port: 8080
2025-07-13 22:47:33.375 [info] [tcpForward][(remote) 127.0.0.1:8080 -> (local) 127.0.0.1:8080] Starting no-op local tunnel
2025-07-13 22:47:39.681 [info] forwarderProcess stdout: forwarder: handleClient subprocess exited with code 0 and signal null

2025-07-13 22:47:39.681 [info] forwarderProcess stdout: forwarder: handleClient subprocess closed

2025-07-13 22:51:25.834 [info] forwarderProcess stdout: forwarder: handleClient subprocess exited with code 1 and signal null

2025-07-13 22:51:25.835 [info] forwarderProcess stdout: forwarder: handleClient subprocess closed

2025-07-13 22:51:25.835 [error] forwarderProcess stderr: forwarder error: startServer error: handleClient subprocess exited with code 1 and signal null

2025-07-13 22:51:25.915 [info] forwarderProcess stdout: forwarder: handleClient subprocess exited with code 1 and signal null

2025-07-13 22:51:25.915 [error] forwarderProcess stderr: forwarder error: startServer error: handleClient subprocess exited with code 1 and signal null

2025-07-13 22:51:25.915 [info] forwarderProcess stdout: forwarder: handleClient subprocess closed

Hi @tl-jacob , @colachg , and @Wet_Rain , thank you for your patience as we worked through the issue with SSH agent forwarding. We just released version 1.0.15 of the Remote Containers extension, which has a completely new implementation for the socket forwarding to hopefully make it faster and more reliable. Could you try upgrading to the latest version of the extension and see whether that fixes the problem?

I think there is still a bug in the current version. If you are using another shell like zsh in your SSH or local session and then launch a devcontainer it appears that the $SSH_AUTH_SOCK variable is not inherited unless explicitly passed to that shell.

It appears that the shell that is invoking the devcontainer build steps and then connecting is not inheriting this variable correctly from what I can see leading to the loss of connection.

Upon some further investigation it appears that only the .bash_profile is loaded so if your code for the SSH agent is in .zprofile or another shell’s machinery then the settings will not take effect.

You should probably change or document this for future users.

1 Like