Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSH_AUTH_SOCK is not set when connecting to remote containers #2926

Closed
andyljones opened this issue May 4, 2020 · 3 comments
Closed

SSH_AUTH_SOCK is not set when connecting to remote containers #2926

andyljones opened this issue May 4, 2020 · 3 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug containers Issue in vscode-remote containers info-needed Issue requires more information from poster

Comments

@andyljones
Copy link

Connecting to a remote container, SSH agent forwarding doesn't work and SSH_AUTH_SOCK is an empty string. Setting SSH_AUTH_SOCK to point at the vscode-ssh-auth socket in /tmp gets it to work.

  • VSCode Version: 1.44.2
  • Local OS Version: macOS 10.15.2
  • Remote OS Version: macOS 10.15.2/docker desktop 19.03.8
  • Remote Extension/Connection Type: Docker attach-to-running-container

Steps to Reproduce:

For an exemplar container, I've followed this vscode tutorial:

git clone https://github.com/microsoft/vscode-express-sample.git
cd vscode-express-sample
docker-compose up
code .

Then from vscode, click through Remote Explorer -> right-click on container -> Attach to Container.

Within the window that opens inside the container, create a new terminal.

Test out ssh with ssh -T git@github.com. It'll fail.

Run echo $SSH_AUTH_SOCK. It'll return an empty string.

Run export SSH_AUTH_SOCK=$(ls -t /tmp/vscode-ssh-auth* | head -1) to set SSH_AUTH_SOCK.

Test out ssh with ssh -T git@github.com. It'll work!

Does this issue occur when you try this locally?: N/A
Does this issue occur when you try this locally and all extensions are disabled?: N/A

Notes

No extra extensions are installed remotely.

This might be related to this issue, but the poster there reports SSH_AUTH_SOCK being set.

Here's my dev-container logs:

[0 ms] Start: Resolving remote
[1 ms] Setting up container /eloquent_yonath

[2 ms] Start: Run: docker inspect --type container /eloquent_yonath
[1284 ms] Start: Check Docker is running
[1284 ms] Start: Run: docker info
[1670 ms] Start: Inspecting container
[1670 ms] Start: Run: docker inspect --type container e924a1abf7fa583d6c62e9007c11999988a60016aef50b8d99afdd37afb000bb
[2002 ms] Start: Run: docker exec -i -u root -e VSCODE_REMOTE_CONTAINERS_SESSION=a25b1876-edcf-46e6-ad13-e1b832ff9a8e1588587688159 e924a1abf7fa583d6c62e9007c11999988a60016aef50b8d99afdd37afb000bb /bin/sh
[2006 ms] Start: Run in container: uname -m
[2787 ms] x86_64
[2787 ms] 
[2787 ms] Start: Run in container: (cat /etc/os-release || cat /usr/lib/os-release) 2>/dev/null
[2795 ms] PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
[2795 ms] 
[2795 ms] Start: Run in container: cat /etc/passwd
[2801 ms] Start: Run in container: test -d /root/.vscode-server
[2806 ms] 
[2806 ms] 
[2806 ms] Exit code 1
[2806 ms] Start: Run in container: test -d /root/.vscode-remote
[2812 ms] 
[2812 ms] 
[2812 ms] Exit code 1
[2812 ms] Start: Run in container: set -o noclobber ; mkdir -p '/root/.vscode-server/data/Machine' && { > '/root/.vscode-server/data/Machine/.writeMachineSettingsMarker' ; } 2> /dev/null
[2820 ms] 
[2820 ms] 
[2821 ms] Start: Run in container: test -d /root/.vscode-server/bin/ff915844119ce9485abfe8aa9076ec76b5300ddd
[2826 ms] 
[2826 ms] 
[2826 ms] Exit code 1
[2827 ms] Installing VS Code Server for commit ff915844119ce9485abfe8aa9076ec76b5300ddd
[2827 ms] Start: Run in container: mkdir -p /root/.vscode-server/bin/ff915844119ce9485abfe8aa9076ec76b5300ddd_1588587691634
[2833 ms] 
[2833 ms] 
[2834 ms] Start: Run: docker exec -i -u root -w /root/.vscode-server/bin/ff915844119ce9485abfe8aa9076ec76b5300ddd_1588587691634 e924a1abf7fa583d6c62e9007c11999988a60016aef50b8d99afdd37afb000bb tar --no-same-owner -xz --strip-components 1
[8041 ms] 
[8042 ms] 
[8042 ms] Start: Run in container: mv -n /root/.vscode-server/bin/ff915844119ce9485abfe8aa9076ec76b5300ddd_1588587691634 /root/.vscode-server/bin/ff915844119ce9485abfe8aa9076ec76b5300ddd
[8048 ms] 
[8048 ms] 
[8048 ms] Start: Launching Remote-Containers helper.
[8050 ms] Start: Run in container: # Copy .gitconfig
[8056 ms] 
[8056 ms] 
[8056 ms] Start: Run in container: cat <<'EOF-/tmp/vscode-remote-containers-9246fb80428cc6b91ae1ad6d4f948e1e936d94b6.js' >/tmp/vscode-remote-containers-9246fb80428cc6b91ae1ad6d4f948e1e936d94b6.js
[8064 ms] 
[8064 ms] 
[8064 ms] Start: Run in container: command -v git >/dev/null 2>&1 && git config --global credential.helper '!f() { /root/.vscode-server/bin/ff915844119ce9485abfe8aa9076ec76b5300ddd/node /tmp/vscode-remote-containers-9246fb80428cc6b91ae1ad6d4f948e1e936d94b6.js $*; }; f' || true
[8072 ms] 
[8072 ms] 
[8072 ms] Start: Run in container: set -o noclobber ; mkdir -p '/root/.vscode-server/data/Machine' && { > '/root/.vscode-server/data/Machine/.installExtensionsMarker' ; } 2> /dev/null
[8078 ms] 
[8078 ms] 
[8080 ms] Start: Run in container: cd /root/.vscode-server/bin/ff915844119ce9485abfe8aa9076ec76b5300ddd; export VSCODE_AGENT_FOLDER=/root/.vscode-server; /root/.vscode-server/bin/ff915844119ce9485abfe8aa9076ec76b5300ddd/server.sh --install-extension ms-python.python --force
[57437 ms] Installing extensions...
Installing extension 'ms-python.python' v2020.4.76186...
[57437 ms] Corrupt ZIP: end of central directory record signature not found
[57437 ms] Exit code 1
[57438 ms] Start: Run in container: for pid in `cd /proc && ls -d [0-9]*`; do { echo $pid ; readlink -f /proc/$pid/cwd ; xargs -0 < /proc/$pid/environ ; xargs -0 < /proc/$pid/cmdline ; } ; echo ; done 2>/dev/null
[57476 ms] Start: Run: docker exec -i -u root -e SHELL=/bin/bash -e VSCODE_AGENT_FOLDER=/root/.vscode-server -w /root/.vscode-server/bin/ff915844119ce9485abfe8aa9076ec76b5300ddd e924a1abf7fa583d6c62e9007c11999988a60016aef50b8d99afdd37afb000bb /root/.vscode-server/bin/ff915844119ce9485abfe8aa9076ec76b5300ddd/server.sh --disable-user-env-probe --port 0
[58819 ms] 

*
* Visual Studio Code Server
*
* Reminder: You may only use this software with Visual Studio family products,
* as described in the license https://aka.ms/vscode-remote/license
*


[58856 ms] IP Address: 172.17.0.3
Extension host agent listening on 33655


[10:22:27] Extension host agent started.
[58856 ms] Start: Run in container: echo 33655 >/root/.vscode-server/bin/ff915844119ce9485abfe8aa9076ec76b5300ddd/.devport
[58863 ms] 
[58864 ms] 
[58866 ms] Forwarding local port 33655 to container port 33655
[58867 ms] Start: Run: docker exec -i -u root -w /root/.vscode-server/extensions e924a1abf7fa583d6c62e9007c11999988a60016aef50b8d99afdd37afb000bb /bin/sh -c # Watch installed extensions
[58867 ms] Start: Run: docker exec -i -u root -w /root/.vscode-server/data/Machine e924a1abf7fa583d6c62e9007c11999988a60016aef50b8d99afdd37afb000bb /bin/sh -c # Watch machine settings
[58978 ms] Start: Run: docker exec -i -u root -e VSCODE_REMOTE_CONTAINERS_SESSION=a25b1876-edcf-46e6-ad13-e1b832ff9a8e1588587688159 e924a1abf7fa583d6c62e9007c11999988a60016aef50b8d99afdd37afb000bb /root/.vscode-server/bin/ff915844119ce9485abfe8aa9076ec76b5300ddd/node -e 
[58981 ms] Start: Run: docker exec -i -u root -e VSCODE_REMOTE_CONTAINERS_SESSION=a25b1876-edcf-46e6-ad13-e1b832ff9a8e1588587688159 e924a1abf7fa583d6c62e9007c11999988a60016aef50b8d99afdd37afb000bb /root/.vscode-server/bin/ff915844119ce9485abfe8aa9076ec76b5300ddd/node -e 
[60437 ms] [10:22:29] [::ffff:127.0.0.1][b8339516][ManagementConnection] New connection established.
[60666 ms] [10:22:29] [::ffff:127.0.0.1][9890348f][ExtensionHostConnection] New connection established.
[60672 ms] [10:22:29] [::ffff:127.0.0.1][9890348f][ExtensionHostConnection] <167> Launched Extension Host Process.
[119971 ms] Start: Run: docker exec -i -u root -w /root/.vscode-server/extensions e924a1abf7fa583d6c62e9007c11999988a60016aef50b8d99afdd37afb000bb /bin/sh -c # Watch installed extensions
@chrmarti chrmarti added this to the May 2020 milestone May 5, 2020
@chrmarti chrmarti self-assigned this May 5, 2020
@chrmarti chrmarti added bug Issue identified by VS Code Team member as probable bug containers Issue in vscode-remote containers labels May 5, 2020
@chrmarti chrmarti modified the milestones: May 2020, June 2020 Jun 4, 2020
@chrmarti
Copy link
Contributor

chrmarti commented Jun 5, 2020

Make sure you have 'Inherit Env' enabled in the settings:
image

@chrmarti chrmarti removed this from the June 2020 milestone Jun 5, 2020
@chrmarti chrmarti added the info-needed Issue requires more information from poster label Jun 5, 2020
@andyljones
Copy link
Author

Success!

Well damn, I have no idea when I disabled that. Sorry for the inconvenience, and thanks for the simple solution.

@andyljones
Copy link
Author

Figured out why I turned it off: when using a conda env, there's a prompt suggesting to turn inheritEnv off.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug containers Issue in vscode-remote containers info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants