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

[Remote-SSH Bug]: failed to create symbolic link #7853

Closed
5 tasks done
vvbogdanov87 opened this issue Jan 13, 2023 · 5 comments
Closed
5 tasks done

[Remote-SSH Bug]: failed to create symbolic link #7853

vvbogdanov87 opened this issue Jan 13, 2023 · 5 comments
Assignees
Labels
info-needed Issue requires more information from poster ssh Issue in vscode-remote SSH

Comments

@vvbogdanov87
Copy link

Is there an existing issue for this bug?

  • I have searched the existing issues

Debugging Steps

  • I have followed these debugging steps
  • I have tried both values of the remote.SSH.useLocalServer setting
  • My SSH command works from a local terminal
  • I can connect using the Remote-SSH extension on VS Code when all other VS Code extensions are disabled

->

No response

Versions

  • VS Code Version: 1.74.2
  • Remote OS Version: Debian 11

Expected Behavior

In my setup when I ssh to a remote server my user is changed to admin(this is pretty common practice in many organizations). The last line in my user's .zshrc is /usr/bin/sudo --preserve-env /bin/su admin. In order to run vscode as admin user and be able to edit files I added RemoteCommand /usr/bin/sudo --preserve-env /bin/su admin to ssh config file.
The problem is that I can't use vscode to push to remote git. This is because vscode tries to create ssh auth socket under my original user instead of admin. Here is the output from vscode terminal:

% id
uid=1000(admin) gid=1000(admin) groups=1000(admin)

% echo $SSH_AUTH_SOCK
/run/user/11161/vscode-ssh-auth-sock-968104192

% ls -al /run/user/11161            
total 0
drwxr-xr-x 4 <MY ORIGINAL USER> <MY ORIGINAL USER> 100 Jan 13 21:26 ./
drwxr-xr-x 4 root      root       80 Jan 13 18:36 ../
srw-rw-rw- 1 <MY ORIGINAL USER> <MY ORIGINAL USER>   0 Jan 13 18:36 bus=
drwx------ 2 <MY ORIGINAL USER> <MY ORIGINAL USER> 140 Jan 13 18:36 gnupg/
drwxr-xr-x 2 <MY ORIGINAL USER> <MY ORIGINAL USER>  80 Jan 13 18:36 systemd/

% id <MY ORIGINAL USER>
uid=11161...

Because auth socket is not created, git can't access my private key via ssh-agent forwarding.

Steps To Reproduce

No response

Remote-SSH Log

Remote-SSH Log

[13:41:14.537] Log Level: 2
[13:41:14.540] remote-ssh@0.94.0
[13:41:14.540] darwin x64
[13:41:14.545] SSH Resolver called for "****", attempt 1
[13:41:14.545] "remote.SSH.useLocalServer": true
[13:41:14.545] "remote.SSH.path": undefined
[13:41:14.545] "remote.SSH.configFile": ***
[13:41:14.546] "remote.SSH.useFlock": true
[13:41:14.546] "remote.SSH.lockfilesInTmp": false
[13:41:14.546] "remote.SSH.localServerDownload": auto
[13:41:14.546] "remote.SSH.remoteServerListenOnSocket": false
[13:41:14.546] "remote.SSH.showLoginTerminal": false
[13:41:14.546] "remote.SSH.defaultExtensions": ["redhat.java"]
[13:41:14.546] "remote.SSH.loglevel": 2
[13:41:14.546] "remote.SSH.enableDynamicForwarding": true
[13:41:14.547] "remote.SSH.enableRemoteCommand": true
[13:41:14.547] "remote.SSH.serverPickPortsFromRange": {}
[13:41:14.547] "remote.SSH.serverInstallPath": {}
[13:41:14.551] SSH Resolver called for host: ***
[13:41:14.551] Setting up SSH remote "***"
[13:41:14.554] Acquiring local install lock: /var/folders/zj/bs110bp972q2742kpgwt6q_m0000gq/T/vscode-remote-ssh-18575fe4-install.lock
[13:41:14.555] Looking for existing server data file at /Users/***/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-18575fe4-e8a3071ea4344d9d48ef8a4df2c097372b0c5161-0.94.0/data.json
[13:41:14.555] Using commit id "e8a3071ea4344d9d48ef8a4df2c097372b0c5161" and quality "stable" for server
[13:41:14.559] Install and start server if needed
[13:41:14.563] PATH: /Users/***/google-cloud-sdk/bin:/Users/***/.nvm/versions/node/v14.19.0/bin:/Users/***/miniconda3/condabin:/Users/***/.rbenv/shims:/Users/***/.pyenv/shims::/Library/groovy/current/bin:/opt/apache-maven-3.8.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/opt/puppetlabs/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/***/go/bin
[13:41:14.563] Checking ssh with "ssh -V"
[13:41:14.575] > OpenSSH_8.6p1, LibreSSL 3.3.6

[13:41:14.579] Using SSH config file "***"
[13:41:14.580] askpass server listening on /var/folders/zj/bs110bp972q2742kpgwt6q_m0000gq/T/vscode-ssh-askpass-cdc9d804c2294b3dfdcf3273bb6d00998a9e2116.sock
[13:41:14.590] Spawning local server with {"serverId":1,"ipcHandlePath":"/var/folders/zj/bs110bp972q2742kpgwt6q_m0000gq/T/vscode-ssh-askpass-567ce4af21e01e21ec2e98e1c8b740edceb27d46.sock","sshCommand":"ssh","sshArgs":["-v","-T","-D","57868","-o","ConnectTimeout=15","-F","***","***"],"serverDataFolderName":".vscode-server","dataFilePath":"/Users/***/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-18575fe4-e8a3071ea4344d9d48ef8a4df2c097372b0c5161-0.94.0/data.json"}
[13:41:14.590] Local server env: {"SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.hV2RmX9gHh/Listeners","SHELL":"/bin/zsh","DISPLAY":"1","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"/Users/***/.vscode/extensions/ms-vscode-remote.remote-ssh-0.94.0/out/local-server/askpass.sh","VSCODE_SSH_ASKPASS_NODE":"/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper","VSCODE_SSH_ASKPASS_EXTRA_ARGS":"--ms-enable-electron-run-as-node","VSCODE_SSH_ASKPASS_MAIN":"/Users/***/.vscode/extensions/ms-vscode-remote.remote-ssh-0.94.0/out/askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"/var/folders/zj/bs110bp972q2742kpgwt6q_m0000gq/T/vscode-ssh-askpass-cdc9d804c2294b3dfdcf3273bb6d00998a9e2116.sock"}
[13:41:14.591] Spawned 35768
[13:41:14.725] > local-server-1> Running ssh connection command: "-v -T -D 57868 -o ConnectTimeout=15 -F *** ***"
[13:41:14.729] > local-server-1> Spawned ssh, pid=35778
[13:41:14.734] stderr> OpenSSH_8.6p1, LibreSSL 3.3.6
[13:41:14.817] stderr> Waiting for ssh
[13:41:15.258] stderr> debug1: Server host key: ssh-ed25519 SHA256:Xc6m2QyNkDydGl6iWyLIYt0P2uw/jTxXjjm2niBC3b0
[13:41:15.259] stderr> Warning: Permanently added '10.254.86.127' (ED25519) to the list of known hosts.
[13:41:15.468] stderr> Authenticated to 10.254.86.127 (via proxy).
[13:41:16.279] > ready: ae2713a1da9c
[13:41:16.309] > Linux 4.19.0-23-cloud-amd64 #1 SMP Debian 4.19.269-1 (2022-12-20)
[13:41:16.310] Platform: linux
[13:41:16.340] > /bin/zsh
[13:41:16.340] Shell: zsh
[13:41:16.340] Creating bash subshell inside "zsh"
[13:41:16.411] > bash version:  5.0.3(1)-release
[13:41:16.436] > bash version:  5.0.3(1)-release
[13:41:16.508] > ae2713a1da9c: running
[13:41:16.518] > Acquiring lock on /home/admin/.vscode-server/bin/e8a3071ea4344d9d48ef8a4df2c097372b0c5161/vscode-remote-lock.admin.e8a3071ea4344d9d48ef8a4df2c097372b0c5161
[13:41:16.523] > Found existing installation at /home/admin/.vscode-server/bin/e8a3071ea4344d9d48ef8a4df2c097372b0c5161...
> Checking /home/admin/.vscode-server/.e8a3071ea4344d9d48ef8a4df2c097372b0c5161.log and /home/admin/.vscode-server/.e8a3071ea4344d9d48ef8a4df2c097372b0c5161.pid for a running server
[13:41:16.524] > Looking for server with pid: 15100
[13:41:16.536] > Found running server...
> Installing extensions...
[13:41:16.808] > Installing extensions...
[13:41:16.870] > Extension 'redhat.java' v1.13.0 is already installed. Use '--force' option to update to latest version or provide '@<version>' to install a specific version, for example: 'redhat.java@1.2.3'.
[13:41:16.883] >  
> *
> * Visual Studio Code Server
> *
> * By using the software, you agree to
> * the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-license) and
> * the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacystatement).
> *
>  
[13:41:16.908] > Checking server status on port 45609 with wget
> ae2713a1da9c: start
> SSH_AUTH_SOCK==/tmp/ssh-584CdadNq4/agent.20871==
> DISPLAY====
> webUiAccessToken====
> listeningOn==45609==
> osReleaseId==debian==
> arch==x86_64==
> tmpDir==/run/user/11161==
> platform==linux==
> unpackResult====
> didLocalDownload==0==
> downloadTime====
> installTime====
> extInstallTime==343==
> serverStartTime====
> connectionToken==1111a1a1-aa1a-1aa1-aaa1-11aa1a1aa1a1==
> ae2713a1da9c: end
[13:41:16.909] Received install output: 
SSH_AUTH_SOCK==/tmp/ssh-584CdadNq4/agent.20871==
DISPLAY====
webUiAccessToken====
listeningOn==45609==
osReleaseId==debian==
arch==x86_64==
tmpDir==/run/user/11161==
platform==linux==
unpackResult====
didLocalDownload==0==
downloadTime====
installTime====
extInstallTime==343==
serverStartTime====
connectionToken==1111a1a1-aa1a-1aa1-aaa1-11aa1a1aa1a1==

[13:41:16.909] Remote server is listening on 45609
[13:41:16.910] Parsed server configuration: {"serverConfiguration":{"remoteListeningOn":{"port":45609},"osReleaseId":"debian","arch":"x86_64","webUiAccessToken":"","sshAuthSock":"/tmp/ssh-584CdadNq4/agent.20871","display":"","tmpDir":"/run/user/11161","platform":"linux","connectionToken":"1111a1a1-aa1a-1aa1-aaa1-11aa1a1aa1a1"},"extInstallTime":343,"installUnpackCode":""}
[13:41:16.910] Persisting server connection details to /Users/***/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-18575fe4-e8a3071ea4344d9d48ef8a4df2c097372b0c5161-0.94.0/data.json
[13:41:16.914] Starting forwarding server. localPort 57882 -> socksPort 57868 -> remotePort 45609
[13:41:16.914] Forwarding server listening on 57882
[13:41:16.915] Waiting for ssh tunnel to be ready
[13:41:16.916] Tunneled 45609 to local port 57882
[13:41:16.916] Resolved "ssh-remote+***" to "127.0.0.1:57882"
[13:41:16.917] Updating $SSH_AUTH_SOCK: ln -f -s "/tmp/ssh-584CdadNq4/agent.20871" "/run/user/11161/vscode-ssh-auth-sock-798373379"
[13:41:16.917] Using cwd: vscode-remote://ssh-remote%2B***/
[13:41:16.917] Remote extension host environment: {"SSH_AUTH_SOCK":"/run/user/11161/vscode-ssh-auth-sock-798373379"}
[13:41:16.918] [Forwarding server 57882] Got connection 0
[13:41:16.928] ------




[13:41:17.020] [Forwarding server 57882] Got connection 1
[13:41:17.101] [Forwarding server 57882] Got connection 2
[13:41:18.124] [Forwarding server 57882] Got connection 3
[13:41:18.125] [Forwarding server 57882] Got connection 4
[13:41:19.279] > ln: failed to create symbolic link '/run/user/11161/vscode-ssh-auth-sock-798373379': Permission denied
[13:41:19.525] "Update SSH_AUTH_SOCK" terminal command done
[13:41:19.525] "Update SSH_AUTH_SOCK" task produced unexpected output, it may have failed

Anything else?

No response

@vvbogdanov87 vvbogdanov87 added the ssh Issue in vscode-remote SSH label Jan 13, 2023
@eleanorjboyd
Copy link
Member

Hello! I am seeing the error [13:41:19.279] > ln: failed to create symbolic link '/run/user/11161/vscode-ssh-auth-sock-798373379': Permission denied. Does it work to use sudo on your remote machine when connecting via the terminal? I am seeing this exchange with reference to the error you are receiving: https://askubuntu.com/questions/957736/permission-denied-to-create-a-symbolic-link-sudo-errors-out. If your sudo works just let me know and I will continue investigating on our end. Thanks

@eleanorjboyd eleanorjboyd added the info-needed Issue requires more information from poster label Jan 19, 2023
@vvbogdanov87
Copy link
Author

Remote-SSH Log

[14:10:32.054] Updating $SSH_AUTH_SOCK: ln -f -s "/home/admin/.ssh/ssh_auth_sock" "/run/user/11161/vscode-ssh-auth-sock-177763752"
[14:10:32.054] Using cwd: vscode-remote://ssh-remote%2B***/
[14:10:32.054] Remote extension host environment: {"SSH_AUTH_SOCK":"/run/user/11161/vscode-ssh-auth-sock-177763752"}
[14:10:32.055] [Forwarding server 50396] Got connection 0
[14:10:32.063] ------

[14:10:32.157] [Forwarding server 50396] Got connection 1
[14:10:32.308] [Forwarding server 50396] Got connection 2
[14:10:33.855] > ln: failed to access '/run/user/11161/vscode-ssh-auth-sock-177763752': Permission denied
[14:10:34.359] "Update SSH_AUTH_SOCK" terminal command done
[14:10:34.360] "Update SSH_AUTH_SOCK" task produced unexpected output, it may have failed

From vscode terminal:

% ls -al /home/admin/.ssh/ssh_auth_sock 
lrwxrwxrwx 1 admin admin 31 Jan 19 22:09 /home/admin/.ssh/ssh_auth_sock -> /tmp/ssh-tnAc6dRoq9/agent.17036=


% ln -f -s "/home/admin/.ssh/ssh_auth_sock" "/run/user/11161/vscode-ssh-auth-sock-177763752"
ln: failed to access '/run/user/11161/vscode-ssh-auth-sock-177763752': Permission denied


% sudo ln -f -s "/home/admin/.ssh/ssh_auth_sock" "/run/user/11161/vscode-ssh-auth-sock-177763752"
% echo $?
0


% sudo ls -al /run/user/11161
total 0
drwx------ 4 <MY_USER> <MY_USER> 120 Jan 19 22:13 .
drwxr-xr-x 4 root      root       80 Jan 19 22:09 ..
srw-rw-rw- 1 <MY_USER> <MY_USER>   0 Jan 19 22:09 bus
drwx------ 2 <MY_USER> <MY_USER> 140 Jan 19 22:09 gnupg
drwxr-xr-x 2 <MY_USER> <MY_USER>  80 Jan 19 22:09 systemd
lrwxrwxrwx 1 root      root       30 Jan 19 22:13 vscode-ssh-auth-sock-177763752 -> /home/admin/.ssh/ssh_auth_sock

@eleanorjboyd eleanorjboyd changed the title [Remote-SSH Bug]: [Remote-SSH Bug]: failed to create symbolic link Jan 20, 2023
@eleanorjboyd
Copy link
Member

sorry for the delay- I'm going to attempt to repro. Thanks

@eleanorjboyd
Copy link
Member

Hello! It looks like this is a duplicate of this issue, there seem to be some suggestions on what fixes might be on here as well as a discussion on issues/ status. Thanks

@eleanorjboyd eleanorjboyd closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2023
@vvbogdanov87
Copy link
Author

@eleanorjboyd I don't think these issues are related. I can confirm that in my setup vscode server side is running under admin user which is correct. But vscode tries to create a symbolic link in a folder owned by a user which was used to connect to the server. My guess is that vscode server uses the username and id of the "original" user instead of the "current" user.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster ssh Issue in vscode-remote SSH
Projects
None yet
Development

No branches or pull requests

2 participants