ssh in vscode error: Permission denied (publickey,password)
ssh in vscode error: Permission denied (publickey,password)
所以我在 VSCode 中使用 "Remote - SSH" 插件连接到我的 VPS 并编辑我的代码。我失去了连接,然后在 30 多分钟后不得不硬重置它。现在我无法再使用 VSCode 访问它 [putty works] 并在 ssh up 中启动 VSCode 或重新加载连接时获得 Could not establish connection to "[vps-ip]". Permission denied (publickey,password).
。
我也是每次都收到这个日志。
我需要做什么才能让它再次正常工作?
这是我用 [...]
替换了一些东西的日志
[18:42:52.792] Log Level: 2
[18:42:52.795] remote-ssh@0.50.0
[18:42:52.795] win32 x64
[18:42:52.797] SSH Resolver called for "ssh-remote+[vps-ip]", attempt 1
[18:42:52.797] SSH Resolver called for host: [vps-ip]
[18:42:52.798] Setting up SSH remote "[vpsip]"
[18:42:52.801] Acquiring local install lock: C:\Users\[myname]\AppData\Local\Temp\vscode-remote-ssh-[vps-ip]-install.lock
[18:42:52.816] Looking for existing server data file at c:\Users\[myname]\AppData\Roaming\Code\User\globalStorage\ms-vscode-remote.remote-ssh\vscode-ssh-host-[vps-ip]-[id]\data.json
[18:42:52.817] Using commit id "[id]" and quality "stable" for server
[18:42:52.817] Install and start server if needed
[18:42:52.820] Checking ssh with "ssh -V"
[18:42:52.875] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[18:42:52.876] Checking ssh with "C:\WINDOWS\System32\OpenSSH\ssh.exe -V"
[18:42:52.917] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[18:42:52.917] Checking ssh with "C:\Program Files\Git\usr\bin\ssh.exe -V"
[18:42:52.993] > OpenSSH_8.1p1, OpenSSL 1.1.1d 10 Sep 2019
[18:42:52.994] askpass server listening on \.\pipe\vscode-ssh-askpass-[askpass]-sock
[18:42:52.995] Spawning local server with {"ipcHandlePath":"\\.\pipe\vscode-ssh-askpass-[askpass]-sock","sshCommand":"C:\Program Files\Git\usr\bin\ssh.exe","sshArgs":["-v","-T","-D","55323","[vps-ip]"],"dataFilePath":"c:\Users\[myname]\AppData\Roaming\Code\User\globalStorage\ms-vscode-remote.remote-ssh\vscode-ssh-host-[vps-ip]-[id]\data.json"}
[18:42:52.995] Local server env: {"DISPLAY":"1","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"c:\Users\[myname]\.vscode\extensions\ms-vscode-remote.remote-ssh-0.50.0\out\local-server\askpass.bat","VSCODE_SSH_ASKPASS_NODE":"C:\Users\[myname]\AppData\Local\Programs\Microsoft VS Code\Code.exe","VSCODE_SSH_ASKPASS_MAIN":"c:\Users\[myname]\.vscode\extensions\ms-vscode-remote.remote-ssh-0.50.0\out\askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"\\.\pipe\vscode-ssh-askpass-[askpass]-sock"}
[18:42:53.021] Spawned 30572
[18:42:53.125] > local-server> Spawned ssh: 12024
[18:42:53.165] stderr> OpenSSH_8.1p1, OpenSSL 1.1.1d 10 Sep 2019
[18:42:53.359] stderr> debug1: Server host key: [the key]
[18:42:53.558] stderr> 'C:\Users\[only my sirname]' is not recognized as an internal or external command,
[18:42:53.558] stderr> operable program or batch file.
[18:42:53.607] stderr> Permission denied, please try again.
[18:42:53.638] stderr> 'C:\Users\[only my sirname]' is not recognized as an internal or external command,
[18:42:53.638] stderr> operable program or batch file.
[18:42:53.686] stderr> Permission denied, please try again.
[18:42:53.716] stderr> 'C:\Users\[only my sirname]' is not recognized as an internal or external command,
[18:42:53.716] stderr> operable program or batch file.
[18:42:53.767] stderr> root@[vps-ip]: Permission denied (publickey,password).
[18:42:53.771] > local-server> ssh child died, shutting down
[18:42:53.779] Local server exit: 0
[18:42:53.780] Received install output: OpenSSH_8.1p1, OpenSSL 1.1.1d 10 Sep 2019
debug1: Server host key: [key]
'C:\Users\[only my sirname]' is not recognized as an internal or external command,
operable program or batch file.
Permission denied, please try again.
'C:\Users\[only my sirname]' is not recognized as an internal or external command,
operable program or batch file.
Permission denied, please try again.
'C:\Users\[only my sirname]' is not recognized as an internal or external command,
operable program or batch file.
root@[vps-ip]: Permission denied (publickey,password).
[18:42:53.781] Resolver error: Permission denied (publickey,password).
[18:42:53.783] ------
EDIT2:很明显,这是一个仅在我的一台 PC 上出现的问题,重新安装也无济于事
似乎远程ssh扩展版本0.50.0破坏了一些与此相关的东西。请参阅我在 Github 上打开的问题:
https://github.com/microsoft/vscode-remote-release/issues/2581
作为一种变通方法,使用 0.49.0 版本对我有效。通过右键单击扩展名称并在对话框中单击 "Install another version..." 和 select 0.49.0 来执行此操作。希望这在次要版本更新中得到解决。
我在 vscode 上使用 0.49+ 版本的 Remote SSH 时遇到了同样的问题。我所做的是 cmd-p
> 连接到 SSH 主机 > 配置 SSH 主机 在我的配置文件中我注意到我有两个条目:
Host <ip>
HostName <name>
User <gungoonsoundcloudwhatsup>
IdentityFile ~/.ssh/file.pub
Host <ip>
HostName <name>
User <gungoonsoundcloudwhatsup>
IdentityFile ~/.ssh/file.pub
所以我删除了一个并将 IdentityFile
从 .pub
文件更改为适当的 rsa
。
这对我有用。
可能是 VSCODE 分机设置中 time_out 低导致的。您可以增加它并重试:ctrl + ,
然后在 extension
部分下找到 REMOTE SSH
并可能将 Connect Timeout
增加到 60
。
以下是我使用的适合我的配置。
Host vs-ssh.visualstudio.com
HostName vs-ssh.visualstudio.com
User git
IdentityFile file_path
IdentitiesOnly yes
所以我在 VSCode 中使用 "Remote - SSH" 插件连接到我的 VPS 并编辑我的代码。我失去了连接,然后在 30 多分钟后不得不硬重置它。现在我无法再使用 VSCode 访问它 [putty works] 并在 ssh up 中启动 VSCode 或重新加载连接时获得 Could not establish connection to "[vps-ip]". Permission denied (publickey,password).
。
我也是每次都收到这个日志。
我需要做什么才能让它再次正常工作?
这是我用 [...]
替换了一些东西的日志[18:42:52.792] Log Level: 2
[18:42:52.795] remote-ssh@0.50.0
[18:42:52.795] win32 x64
[18:42:52.797] SSH Resolver called for "ssh-remote+[vps-ip]", attempt 1
[18:42:52.797] SSH Resolver called for host: [vps-ip]
[18:42:52.798] Setting up SSH remote "[vpsip]"
[18:42:52.801] Acquiring local install lock: C:\Users\[myname]\AppData\Local\Temp\vscode-remote-ssh-[vps-ip]-install.lock
[18:42:52.816] Looking for existing server data file at c:\Users\[myname]\AppData\Roaming\Code\User\globalStorage\ms-vscode-remote.remote-ssh\vscode-ssh-host-[vps-ip]-[id]\data.json
[18:42:52.817] Using commit id "[id]" and quality "stable" for server
[18:42:52.817] Install and start server if needed
[18:42:52.820] Checking ssh with "ssh -V"
[18:42:52.875] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[18:42:52.876] Checking ssh with "C:\WINDOWS\System32\OpenSSH\ssh.exe -V"
[18:42:52.917] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[18:42:52.917] Checking ssh with "C:\Program Files\Git\usr\bin\ssh.exe -V"
[18:42:52.993] > OpenSSH_8.1p1, OpenSSL 1.1.1d 10 Sep 2019
[18:42:52.994] askpass server listening on \.\pipe\vscode-ssh-askpass-[askpass]-sock
[18:42:52.995] Spawning local server with {"ipcHandlePath":"\\.\pipe\vscode-ssh-askpass-[askpass]-sock","sshCommand":"C:\Program Files\Git\usr\bin\ssh.exe","sshArgs":["-v","-T","-D","55323","[vps-ip]"],"dataFilePath":"c:\Users\[myname]\AppData\Roaming\Code\User\globalStorage\ms-vscode-remote.remote-ssh\vscode-ssh-host-[vps-ip]-[id]\data.json"}
[18:42:52.995] Local server env: {"DISPLAY":"1","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"c:\Users\[myname]\.vscode\extensions\ms-vscode-remote.remote-ssh-0.50.0\out\local-server\askpass.bat","VSCODE_SSH_ASKPASS_NODE":"C:\Users\[myname]\AppData\Local\Programs\Microsoft VS Code\Code.exe","VSCODE_SSH_ASKPASS_MAIN":"c:\Users\[myname]\.vscode\extensions\ms-vscode-remote.remote-ssh-0.50.0\out\askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"\\.\pipe\vscode-ssh-askpass-[askpass]-sock"}
[18:42:53.021] Spawned 30572
[18:42:53.125] > local-server> Spawned ssh: 12024
[18:42:53.165] stderr> OpenSSH_8.1p1, OpenSSL 1.1.1d 10 Sep 2019
[18:42:53.359] stderr> debug1: Server host key: [the key]
[18:42:53.558] stderr> 'C:\Users\[only my sirname]' is not recognized as an internal or external command,
[18:42:53.558] stderr> operable program or batch file.
[18:42:53.607] stderr> Permission denied, please try again.
[18:42:53.638] stderr> 'C:\Users\[only my sirname]' is not recognized as an internal or external command,
[18:42:53.638] stderr> operable program or batch file.
[18:42:53.686] stderr> Permission denied, please try again.
[18:42:53.716] stderr> 'C:\Users\[only my sirname]' is not recognized as an internal or external command,
[18:42:53.716] stderr> operable program or batch file.
[18:42:53.767] stderr> root@[vps-ip]: Permission denied (publickey,password).
[18:42:53.771] > local-server> ssh child died, shutting down
[18:42:53.779] Local server exit: 0
[18:42:53.780] Received install output: OpenSSH_8.1p1, OpenSSL 1.1.1d 10 Sep 2019
debug1: Server host key: [key]
'C:\Users\[only my sirname]' is not recognized as an internal or external command,
operable program or batch file.
Permission denied, please try again.
'C:\Users\[only my sirname]' is not recognized as an internal or external command,
operable program or batch file.
Permission denied, please try again.
'C:\Users\[only my sirname]' is not recognized as an internal or external command,
operable program or batch file.
root@[vps-ip]: Permission denied (publickey,password).
[18:42:53.781] Resolver error: Permission denied (publickey,password).
[18:42:53.783] ------
EDIT2:很明显,这是一个仅在我的一台 PC 上出现的问题,重新安装也无济于事
似乎远程ssh扩展版本0.50.0破坏了一些与此相关的东西。请参阅我在 Github 上打开的问题: https://github.com/microsoft/vscode-remote-release/issues/2581
作为一种变通方法,使用 0.49.0 版本对我有效。通过右键单击扩展名称并在对话框中单击 "Install another version..." 和 select 0.49.0 来执行此操作。希望这在次要版本更新中得到解决。
我在 vscode 上使用 0.49+ 版本的 Remote SSH 时遇到了同样的问题。我所做的是 cmd-p
> 连接到 SSH 主机 > 配置 SSH 主机 在我的配置文件中我注意到我有两个条目:
Host <ip>
HostName <name>
User <gungoonsoundcloudwhatsup>
IdentityFile ~/.ssh/file.pub
Host <ip>
HostName <name>
User <gungoonsoundcloudwhatsup>
IdentityFile ~/.ssh/file.pub
所以我删除了一个并将 IdentityFile
从 .pub
文件更改为适当的 rsa
。
这对我有用。
可能是 VSCODE 分机设置中 time_out 低导致的。您可以增加它并重试:ctrl + ,
然后在 extension
部分下找到 REMOTE SSH
并可能将 Connect Timeout
增加到 60
。
以下是我使用的适合我的配置。
Host vs-ssh.visualstudio.com
HostName vs-ssh.visualstudio.com
User git
IdentityFile file_path
IdentitiesOnly yes