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

Remote-SSH: Password prompted again when opening a folder

Open aeschli opened this issue 3 years ago • 27 comments

Testing #6220

Windows Remote-WSL v0.71.2021121615 (pre-release) Version: 1.64.0-insider (user setup) Commit: f93c69659de1a1466bd15e0f1c9f790e73be9208 Date: 2022-01-25T08:42:41.055Z OS: Windows_NT x64 10.0.19044

In #6220, step 3, it says that when I open a new folder, I shouldn't get prompted for a password again.

  • `Connect to Host... pick my host, enter password get the remote window
  • File > Open Folder, pick a folder, window is reopened, trust dialog shows, password input dialog shows

I know I could set up a SSH agent but I haven't done so.

aeschli avatar Jan 25 '22 15:01 aeschli

@aeschli in your settings do you have remote.SSH.useLocalServer: true? We have this issue on Windows for appropriately setting useLocalServer: https://github.com/microsoft/vscode-remote-release/issues/6147#issuecomment-1009599907

tanhakabir avatar Jan 25 '22 17:01 tanhakabir

The Remote-SSH version is now v0.71.2022012519

The settings UI shows this: image so I assume it is set.

I now explicitly put "remote.SSH.useLocalServer": true, but no change. After open Folder I still have to login again.

aeschli avatar Jan 25 '22 20:01 aeschli

Would you be able to share your logs for the reloaded window with the folder?

tanhakabir avatar Jan 25 '22 21:01 tanhakabir

[23:38:22.096] Log Level: 2
[23:38:22.097] [email protected]
[23:38:22.097] win32 x64
[23:38:22.135] SSH Resolver called for "ssh-remote+7b22686f73744e616d65223a224d617274696e2d5043227d", attempt 1
[23:38:22.135] "remote.SSH.useLocalServer": true
[23:38:22.136] "remote.SSH.path": undefined
[23:38:22.136] "remote.SSH.configFile": undefined
[23:38:22.136] "remote.SSH.useFlock": true
[23:38:22.136] "remote.SSH.lockfilesInTmp": false
[23:38:22.136] "remote.SSH.localServerDownload": auto
[23:38:22.137] "remote.SSH.remoteServerListenOnSocket": false
[23:38:22.137] "remote.SSH.showLoginTerminal": false
[23:38:22.137] "remote.SSH.defaultExtensions": []
[23:38:22.137] "remote.SSH.loglevel": 2
[23:38:22.137] "remote.SSH.enableDynamicForwarding": true
[23:38:22.137] "remote.SSH.enableRemoteCommand": false
[23:38:22.138] "remote.SSH.serverPickPortsFromRange": {}
[23:38:22.138] "remote.SSH.serverInstallPath": {}
[23:38:22.138] SSH Resolver called for host: Martin-PC
[23:38:22.138] Setting up SSH remote "Martin-PC"
[23:38:22.141] Acquiring local install lock: C:\Users\martinae\AppData\Local\Temp\vscode-remote-ssh-ba5406f0-install.lock
[23:38:22.143] Looking for existing server data file at c:\Users\martinae\AppData\Roaming\Code - Insiders\User\globalStorage\ms-vscode-remote.remote-ssh\vscode-ssh-host-ba5406f0-f93c69659de1a1466bd15e0f1c9f790e73be9208-0.71.2022012519\data.json
[23:38:22.144] Using commit id "f93c69659de1a1466bd15e0f1c9f790e73be9208" and quality "insider" for server
[23:38:22.149] Install and start server if needed
[23:38:22.154] Checking ssh with "ssh -V"
[23:38:22.193] > OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2

[23:38:22.196] Checking ssh with "C:\WINDOWS\System32\OpenSSH\ssh.exe -V"
[23:38:22.234] > OpenSSH_for_Windows_8.1p1, L
[23:38:22.234] > ibreSSL 3.0.2

[23:38:22.236] Checking ssh with "C:\Program Files\Git\usr\bin\ssh.exe -V"
[23:38:22.271] > OpenSSH_8.4p1, OpenSSL 1.1.1j  16 Feb 2021

[23:38:22.275] Using SSH config file "C:\Users\martinae\.ssh\config"
[23:38:22.275] askpass server listening on \\.\pipe\vscode-ssh-askpass-dce4f037a5c138ddf4bd9be7a219e226517d2cab-sock
[23:38:22.276] Spawning local server with {"serverId":1,"ipcHandlePath":"\\\\.\\pipe\\vscode-ssh-askpass-b8465eb2b4de8d39b539ba258d4eb84b8d6a43b4-sock","sshCommand":"C:\\Program Files\\Git\\usr\\bin\\ssh.exe","sshArgs":["-v","-T","-D","50961","-F","C:\\Users\\martinae\\.ssh\\config","Martin-PC"],"serverDataFolderName":".vscode-server-insiders","dataFilePath":"c:\\Users\\martinae\\AppData\\Roaming\\Code - Insiders\\User\\globalStorage\\ms-vscode-remote.remote-ssh\\vscode-ssh-host-ba5406f0-f93c69659de1a1466bd15e0f1c9f790e73be9208-0.71.2022012519\\data.json"}
[23:38:22.276] Local server env: {"DISPLAY":"1","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"c:\\Users\\martinae\\.vscode-insiders\\extensions\\ms-vscode-remote.remote-ssh-0.71.2022012519\\out\\local-server\\askpass.bat","VSCODE_SSH_ASKPASS_NODE":"C:\\Users\\martinae\\AppData\\Local\\Programs\\Microsoft VS Code Insiders\\Code - Insiders.exe","VSCODE_SSH_ASKPASS_EXTRA_ARGS":"--ms-enable-electron-run-as-node","VSCODE_SSH_ASKPASS_MAIN":"c:\\Users\\martinae\\.vscode-insiders\\extensions\\ms-vscode-remote.remote-ssh-0.71.2022012519\\out\\askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"\\\\.\\pipe\\vscode-ssh-askpass-dce4f037a5c138ddf4bd9be7a219e226517d2cab-sock"}
[23:38:22.285] Spawned 29160
[23:38:22.365] > local-server-1> Spawned ssh, pid=13880
[23:38:22.398] stderr> OpenSSH_8.4p1, OpenSSL 1.1.1j  16 Feb 2021
[23:38:22.436] stderr> debug1: Server host key: ecdsa-sha2-nistp256 SHA256:czu/vEm86e/6TlufN4UDAcO2/0ihZ3CIIUPPYMJwtiA
[23:38:22.564] Got askpass request: {"request":"[email protected]'s password: "}
[23:38:22.565] Showing password prompt
[23:38:22.566] Listening for interwindow password on \\.\pipe\vscode-ssh-askpass-34b17ac28ca2c8d828196fd49544345b5738557e-sock
[23:38:22.566] Writing password prompt to globalState

aeschli avatar Jan 25 '22 22:01 aeschli

with today's build i see the same (this is the only bug i hit in the flow now, aside from the pwsh issue)

sbatten avatar Jan 26 '22 18:01 sbatten

same issue on my win10 laptop. However vscode on my mac only need password and otp once. Both devices share the ssh setting.

Xiao-Chenguang avatar Mar 22 '22 01:03 Xiao-Chenguang

I meet same problem in my win11, but not in linux deepin.

jsboer avatar Oct 28 '22 00:10 jsboer

I have the same problem on MacOs

matija2209 avatar Dec 03 '22 11:12 matija2209

This looks like a real bug in useLocalServer not working correctly. It seems like the local server is getting killed (probably by vscode) whenever the window reloads. I will ask around to see whether anybody knows about this, but we should try old builds to see if we can figure out which vscode version this broke in. At this point I really think it's a vscode issue, not Remote-SSH.

roblourens avatar Dec 13 '22 00:12 roblourens

Actually, it seems that I do the wrong thing for communicating with the local server. Discussion: https://vscodeteam.slack.com/archives/C03ERNTC03X/p1670890778629489

We spawn the local server here and communicate over stdio: https://github.com/microsoft/vscode-remote-ssh/blob/0257ea91b18c4c7c58bb1bcb1c40d4d58c76fe89/open-ssh-remote/src/local-server.ts#L305

But the docs clearly say that when spawning a detached process that will outlive its parent, you have to use stdio: 'ignore': https://nodejs.org/api/child_process.html#optionsdetached

This used to work as long as you didn't write to stdio when the parent was dead. This behavior probably changed with an electron update at some point.

So now, we have to communicate with the local server over an ipc channel instead of stdio. Fortunately, we already have a tcp server set up for communication with the local server, so this should be relatively easy. An alternative is Deepak's suggestion in Slack.

roblourens avatar Dec 13 '22 18:12 roblourens

I want to add to this a similar bug (maybe the same reason?): after you open a new folder (and entering the password again), if you have a .code-workspace file you will be prompted to enter to your workspace, and when you do- you'll have to enter the password yet again!

YoniChechik avatar Mar 05 '23 08:03 YoniChechik

@YoniChechik to confirm this is when you explicitly have "remote.SSH.useLocalServer": true? Ie set in your settings UI or settings json for mac/linux or directly in you're settings.json for windows?

eleanorjboyd avatar Mar 13 '23 16:03 eleanorjboyd

Didn't work with this setting as well

YoniChechik avatar Mar 14 '23 09:03 YoniChechik

I'm having the same issue with the latest vscode/extension. From Windows 10, every time I open a new remote folder, I get prompted for my password. I checked the setting for Use Local Server and it's checked by default

u84six avatar Mar 20 '23 21:03 u84six

@u84six can you open another issue if you are noticing a recent regression? Thanks

eleanorjboyd avatar Mar 22 '23 17:03 eleanorjboyd

@YoniChechik, how many times are you being prompted? if it is more than 2 or 3 please open another issue and we can continue the conversation there. Thanks!

eleanorjboyd avatar Mar 22 '23 17:03 eleanorjboyd

@u84six can you open another issue if you are noticing a recent regression? Thanks

The reason I didn't open a new ticket is because this one already exists... and it's still open

u84six avatar Mar 22 '23 18:03 u84six

@u84six this is an issue that has been known for over a year, has your regression come up more recently or does this align with the timeline you noticed this problem at? Not sure if it has worked for you in the past or if you are just recently using this extension.

eleanorjboyd avatar Mar 22 '23 20:03 eleanorjboyd

@eleanorjboyd my setup is as follows:

I use docker on a remote linux machine (connecting from a personal windows pc).

  1. open vscode on my pc.
  2. use remote-ssh extension to log in to remote linux - password prompt # 1
  3. go to remote-dev-conteiner extension (another open bug https://github.com/microsoft/vscode-remote-release/issues/8242) - password prompt # 2
  4. attach to running container- new vscode window opened- password prompt # 3
  5. open workspace inside docker- password prompt # 4 (this is the current open bug- https://github.com/microsoft/vscode-remote-release/issues/6227 )
  6. Done.

YoniChechik avatar Mar 23 '23 10:03 YoniChechik

@eleanorjboyd my setup is as follows:

I use docker on a remote linux machine (connecting from a personal windows pc).

  1. open vscode on my pc.
  2. use remote-ssh extension to log in to remote linux - password prompt # 1
  3. go to remote-dev-conteiner extension (another open bug [Remote-SSH Bug]: Refresh to provide SSH credentials when SSHing to remote pc and try to open docker conteiners drop-down their #8242) - password prompt # 2
  4. attach to running container- new vscode window opened- password prompt # 3
  5. open workspace inside docker- password prompt # 4 (this is the current open bug- Remote-SSH: Password prompted again when opening a folder #6227 )
  6. Done.

Thank you for saving me the time! :)

u84six avatar Mar 23 '23 13:03 u84six

@u84six this is an issue that has been known for over a year, has your regression come up more recently or does this align with the timeline you noticed this problem at? Not sure if it has worked for you in the past or if you are just recently using this extension.

Well the last time I used these extensions was quite a while ago on a different machine, when the extensions were in the "experimental" stage. I just recently installed the extensions again (after years) and I'm seeing this issue. Whenever I open a new folder after logging in, I get prompted for my password. Can you reproduce this on your end? If not, I'd be really surprised because it seems consistent. The remote machine I ssh to is CentOS v7

u84six avatar Mar 23 '23 14:03 u84six

Hi! Yes that behavior is the current bug we are attempting to fix and will hopefully be resolving soon. Thanks

eleanorjboyd avatar Mar 31 '23 21:03 eleanorjboyd

Hi @eleanorjboyd. Saw this bug deferred twice and now it doesn't appear in June sprint. Any plans to solve this soon?

YoniChechik avatar Jun 14 '23 15:06 YoniChechik

I can confirm that this bug is still a thing to this day.

okunamayanad avatar Nov 09 '23 16:11 okunamayanad

I have this problem but wonder if its because when I setup the SSH key I made it a password protected identity file. Would that make it ask for SSH Password every single time?

philmade avatar Dec 06 '23 14:12 philmade

This isn't necessarily Windows specific. On MacOS and connecting to a Linux machine I have been seeing this for over a year.

Edit: Adding IdentityFile to ssh config actually did not fix

Edit again: ssh-agent did work, thanks for that

matthost avatar Jan 02 '24 17:01 matthost

As this issue has been post for more than two years and not resolved yet, I'd like to share a workaround I found works in MacOs and Window, otherwise we have to roll back to later 2021 version vscode to enjoy one password experience.

The workaround is to turn on both "remote.SSH.useExecServer" and "remote.SSH.useLocalServer".

In case the vscode GUI setting not work properly, add two line to your user setting.json file.

"remote.SSH.useExecServer": true,
"remote.SSH.useLocalServer": true,

If your are using a windows pc, you have to do one more thing, that is use ssh shipped with git. The builtin Openssh in window does not work perfect along vscode. You can install git and find the path of ssh executable in git install folder like C:Program file\git\...\ssh.exe. Then you need to set the Remote.SSH: Path to this new ssh.exe. And you have to set the ssh config file manually in unix style like 'C:/user/usrname/.ssh/config', other your may encounter error not found config file.

And lastly, there is a known limitation of useExecServer when you want to use proxyjump with portforward. I recommend you writ the port forward in the config to workaround this.

Xiao-Chenguang avatar Jun 19 '24 14:06 Xiao-Chenguang

It looks like this no longer reproes with useExecServer=true, and that should be the default now for all users, so I'm going to close this.

roblourens avatar Jul 16 '24 23:07 roblourens