title: VSCode SSH Remote connected to EC2 instance, "shell integration failed to activate" for zsh based terminal
body: <h2>VSCode SSH Remote connected to AWS EC2 instance running Ubuntu 20.04 (ARM64)</h2>
  <p>I'm connecting to the instance using AWS SSM through the Remote SSH extension (see more detail about how here: <a href="https://github.com/aws/aws-toolkit-vscode/issues/941" rel="nofollow noreferrer">https://github.com/aws/aws-toolkit-vscode/issues/941</a>) which is working fine, but zsh shell integration fails with the message <code>Shell integration failed to activate</code>:</p>
  <p><a href="https://i.stack.imgur.com/lhuLh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lhuLh.png" alt="Launching a shell integrated zsh terminal" /></a></p>
  <p><a href="https://i.stack.imgur.com/3Y6X8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Y6X8.png" alt="Resulting in the shell integration failed to activate error" /></a></p>
  <p>Meanwhile, I can easily create a bash based terminal and write <code>$ zsh</code> afterwards:</p>
  <p><a href="https://i.stack.imgur.com/b42KC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b42KC.png" alt="Launching a shell integrated bash termnial" /></a></p>
  <p><a href="https://i.stack.imgur.com/IjFue.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IjFue.png" alt="Resulting in working terminal" /></a></p>
  <p><a href="https://i.stack.imgur.com/pBz3m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pBz3m.png" alt="And manually entering zsh works as well" /></a></p>
  <p>The is the output generated in the <code>Log (Window)</code> Output pane of VSCode:</p>
  <pre><code>[2022-08-09 19:22:35.667] [renderer1] [error] EPERM: operation not permitted, copyfile 
  '/data/home/pens/.vscode-server/bin/da76f93349a72022ca4670c1b84860304616aaa2/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-rc.zsh'
  -&gt; '/tmp/vscode-zsh/.zshrc':
  Error: EPERM: operation not permitted, copyfile
  '/data/home/pens/.vscode-server/bin/da76f93349a72022ca4670c1b84860304616aaa2/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-rc.zsh'
  -&gt; '/tmp/vscode-zsh/.zshrc'
  </code></pre>
  <p>It prints a similar error for the following dot-files files: <code>.zcompdump, .zlogin, .zprofile, .zshenv, .zshrc</code></p>
  <hr />
  <p><strong>Ultimately this means that the issue is related to access to the files in the directory: <code>/tmp/vscode-zsh/</code></strong></p>
  <p>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 <code>permission denied / operation not permitted</code> if the files have already been created for - and are owned by - another user.. Any ideas how to fix this?</p>