vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

VSCode SSH Remote connected to EC2 instance, "shell integration failed to activate" for zsh based terminal

Open nistrup opened this issue 3 years ago • 1 comments

  • VSCode Version: 1.70.0
  • Local OS Version: Windows 10 Enterprise, 21H2
  • Remote OS Version: Ubuntu 20.04.4 LTS
  • Remote Extension/Connection Type: AWS SSM through Remote SSH (see more detail about how here: https://github.com/aws/aws-toolkit-vscode/issues/941)
  • Logs (Remote - SSH):
[19:22:15.015] Log Level: 2
[19:22:15.017] [email protected]
[19:22:15.018] win32 x64
[19:22:15.065] SSH Resolver called for "ssh-remote+i-{redacted}", attempt 1
[19:22:15.066] "remote.SSH.useLocalServer": false
[19:22:15.066] "remote.SSH.showLoginTerminal": false
[19:22:15.067] "remote.SSH.remotePlatform": {"i-{redacted}":"linux"}
[19:22:15.067] "remote.SSH.path": undefined
[19:22:15.067] "remote.SSH.configFile": C:\Users\{redacted}\.ssh\config
[19:22:15.067] "remote.SSH.useFlock": true
[19:22:15.068] "remote.SSH.lockfilesInTmp": false
[19:22:15.068] "remote.SSH.localServerDownload": auto
[19:22:15.068] "remote.SSH.remoteServerListenOnSocket": false
[19:22:15.068] "remote.SSH.showLoginTerminal": false
[19:22:15.068] "remote.SSH.defaultExtensions": []
[19:22:15.068] "remote.SSH.loglevel": 2
[19:22:15.069] "remote.SSH.enableDynamicForwarding": true
[19:22:15.069] "remote.SSH.enableRemoteCommand": false
[19:22:15.069] "remote.SSH.serverPickPortsFromRange": {}
[19:22:15.069] "remote.SSH.serverInstallPath": {}
[19:22:15.108] SSH Resolver called for host: i-{redacted}
[19:22:15.109] Setting up SSH remote "i-{redacted}"
[19:22:15.123] Using commit id "da76f93349a72022ca4670c1b84860304616aaa2" and quality "stable" for server
[19:22:15.130] Install and start server if needed
[19:22:15.138] Checking ssh with "ssh -V"
[19:22:15.284] > O
[19:22:15.284] > penSSH_for_Windows_8.1p1, LibreSSL 3.0.2

[19:22:15.298] Using SSH config file "C:\Users\{redacted}\.ssh\config"
[19:22:15.299] Running script with connection command: ssh -T -D 31212 -F "C:\Users\{redacted}\.ssh\config" "i-{redacted}" bash
[19:22:15.302] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[19:22:16.536] > ]0;C:\WINDOWS\System32\cmd.exe
[19:22:16.537] Got some output, clearing connection timeout
[19:22:20.449] > 64f39d28dfad: running
[19:22:20.491] > Acquiring lock on /home/cjen/.vscode-server/bin/da76f93349a72022ca4670c1b8486030
> 4616aaa2/vscode-remote-lock.cjen.da76f93349a72022ca4670c1b84860304616aaa2       
[19:22:20.516] > Found existing installation at /home/cjen/.vscode-server/bin/da76f93349a72022ca4
> 670c1b84860304616aaa2...
> Checking /home/cjen/.vscode-server/.da76f93349a72022ca4670c1b84860304616aaa2.log
>  and /home/cjen/.vscode-server/.da76f93349a72022ca4670c1b84860304616aaa2.pid for
>  a running server
[19:22:20.531] > Looking for server with pid: 364930
[19:22:20.564] > Found running server...
> 
> *
> * Reminder: You may only use this software with Visual Studio family products, 
> * as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057)
> *
> 
> Checking server status on port 46759 with wget
> 64f39d28dfad: start
> SSH_AUTH_SOCK====
> DISPLAY====
> webUiAccessToken====
> listeningOn==46759==
> osReleaseId==ubuntu==
> arch==aarch64==
> tmpDir==/run/user/1003==
> platform==linux==
> unpackResult====
> didLocalDownload==0==
> downloadTime====
> installTime====
> extInstallTime====
> serverStartTime====
> connectionToken==aa1aa11a-11aa-1111-aa1a-1aa1a111a1a1==
[19:22:20.570] > 
> 64f39d28dfad: end
[19:22:20.570] Received install output: 
SSH_AUTH_SOCK====
DISPLAY====
webUiAccessToken====
listeningOn==46759==
osReleaseId==ubuntu==
arch==aarch64==
tmpDir==/run/user/1003==
platform==linux==
unpackResult====
didLocalDownload==0==
downloadTime====
installTime====
extInstallTime====
serverStartTime====
connectionToken==aa1aa11a-11aa-1111-aa1a-1aa1a111a1a1==

[19:22:20.571] Remote server is listening on 46759
[19:22:20.571] Parsed server configuration: {"serverConfiguration":{"remoteListeningOn":{"port":46759},"osReleaseId":"ubuntu","arch":"aarch64","webUiAccessToken":"","sshAuthSock":"","display":"","tmpDir":"/run/user/1003","platform":"linux","connectionToken":"aa1aa11a-11aa-1111-aa1a-1aa1a111a1a1"},"installUnpackCode":""}
[19:22:20.571] ** Note: Support for architecture "aarch64" is in preview **
[19:22:20.574] Starting forwarding server. localPort 31225 -> socksPort 31212 -> remotePort 46759
[19:22:20.575] Forwarding server listening on 31225
[19:22:20.575] Waiting for ssh tunnel to be ready
[19:22:20.576] > 
[19:22:20.577] [Forwarding server 31225] Got connection 0
[19:22:20.578] Tunneled 46759 to local port 31225
[19:22:20.578] Resolved "ssh-remote+i-{redacted}" to "127.0.0.1:31225"
[19:22:20.594] ------




[19:22:20.618] [Forwarding server 31225] Got connection 1
[19:22:20.686] [Forwarding server 31225] Got connection 2

  • Logs (Window): [2022-08-09 19:22:35.667] [renderer1] [error] EACCES: permission denied, copyfile '/data/home/cjen/.vscode-server/bin/da76f93349a72022ca4670c1b84860304616aaa2/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-rc.zsh' -> '/tmp/vscode-zsh/.zshrc': Error: EACCES: permission denied, copyfile '/data/home/cjen/.vscode-server/bin/da76f93349a72022ca4670c1b84860304616aaa2/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-rc.zsh' -> '/tmp/vscode-zsh/.zshrc'

Ultimately this means that the issue is related to access to the files in the directory: /tmp/vscode-zsh/

VSCode tries to create the 5 dot-files in the same folder with the same naming for the current user whenever it tries to launch a shell integrated zsh terminal. This results in permission denied / operation not permitted if the files have already been created for - and are owned by - another user..

I've also created this as a thread in SO to try to find a workaround: https://stackoverflow.com/questions/73292777/vscode-ssh-remote-connected-to-ec2-instance-shell-integration-failed-to-activa and as an issue on the main VSCode github: https://github.com/microsoft/vscode/issues/157693 because I'm quite frankly unsure where the issue is from a VSCode point-of-view.

Steps to Reproduce:

  1. Have multiple users on the same machine with zsh as their default shell
  2. Try launching a zsh based terminal from VSCode (this will work the first time)
  3. Have another user try launching a zsh based terminal from their VSCode (this will fail because the dot-files already exist in the /tmp/vscode-zsh/ directoy, owned by another user)

Does this issue occur when you try this locally?: This is only an issue when there are multiple users trying to use the shell integrated zsh terminal Does this issue occur when you try this locally and all extensions are disabled?: No

nistrup avatar Aug 09 '22 18:08 nistrup

I had the same issue as yours. You can refer to this issue vscode#157611

jinzcdev avatar Aug 10 '22 00:08 jinzcdev

/duplicate https://github.com/microsoft/vscode/issues/157611

Tyriar avatar Aug 10 '22 14:08 Tyriar