【问题标题】:Permission Denied when connecting vs code to remote server(linux)将vs代码连接到远程服务器(linux)时权限被拒绝
【发布时间】:2022-01-25 00:20:22
【问题描述】:

我正在尝试使用 VS Code 连接虚拟机 (Linux)。 尝试使用 VS 代码登录时出现权限被拒绝错误。

日志-

[15:13:47.479] Log Level: 2
[15:13:47.488] remote-ssh@0.70.0
[15:13:47.488] win32 x64
[15:13:47.491] SSH Resolver called for "ssh-remote+<...>.com", attempt 1
[15:13:47.493] "remote.SSH.useLocalServer": false
[15:13:47.493] "remote.SSH.showLoginTerminal": false
[15:13:47.493] "remote.SSH.remotePlatform": {}
[15:13:47.493] "remote.SSH.path": undefined
[15:13:47.494] "remote.SSH.configFile": undefined
[15:13:47.494] "remote.SSH.useFlock": true
[15:13:47.494] "remote.SSH.lockfilesInTmp": false
[15:13:47.494] "remote.SSH.localServerDownload": auto
[15:13:47.494] "remote.SSH.remoteServerListenOnSocket": false
[15:13:47.495] "remote.SSH.showLoginTerminal": false
[15:13:47.495] "remote.SSH.defaultExtensions": []
[15:13:47.495] "remote.SSH.loglevel": 2
[15:13:47.495] "remote.SSH.serverPickPortsFromRange": {}
[15:13:47.495] "remote.SSH.enableDynamicForwarding": true
[15:13:47.496] "remote.SSH.serverInstallPath": {}
[15:13:47.498] SSH Resolver called for host: <...>.com
[15:13:47.498] Setting up SSH remote "<...>.com"
[15:13:47.536] Using commit id "899d46d82c4c95423fb7e10e68eba52050e30ba3" and quality "stable" for server
[15:13:47.544] Install and start server if needed
[15:13:52.096] Checking ssh with "ssh -V"
[15:13:52.200] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5

[15:13:52.208] Running script with connection command: ssh -T -D 49695 "<...>.com" bash
[15:13:52.214] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[15:14:16.296] > no such identity: <...>.pem: No such file or directory
> ]0;C:\WINDOWS\System32\cmd.exeno such identity: <...>.pem: No such file or directory
> <....>.com: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

配置文件-

Host <...>
  HostName <....>
  IdentityFile <...>.pem
  User <..>

将 pem 文件移至 .ssh 目录

PS C:\Users\HP\.ssh> ls


    Directory: C:\Users\HP\.ssh


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         8/30/2021  10:41 AM           1675 <...>.pem
-a----        12/24/2021   3:34 PM             91 config

我可以使用 PowerShell 或 putty 连接到 VM,但无法使用 VS Code 连接。

【问题讨论】:

    标签: visual-studio-code


    【解决方案1】:

    从日志文件的外观来看,它无法在您声明的文件夹中找到您的 PEM ssh 密钥文件

     no such identity: <...>.pem: No such file or directory
     Permission denied (publickey,gssapi-keyex,gssapi-with-mic)
    

    【讨论】:

    • 我的 .pem 文件位于“C:\Users\HP\Downloads”位置,您能告诉我应该将 .pem 文件放在哪里来消除此错误吗?
    • ssh 密钥文件应该在 C:\Users\HP\.ssh 我通常使用 id_rsa 文件而不是 pem 但应该以相同的方式工作
    • 在 .ssh 中添加了 .pem 文件,但仍然面临同样的错误
    • 如果从 ssh 配置中删除 IdentityFile <...>.pem 行会发生什么?
    • 通过在终端/PowerShell 窗口中运行以下命令来适当地替换 user@hostname 来验证您是否可以连接到 SSH 主机。 ssh 用户@主机名
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-01
    • 2015-06-16
    • 1970-01-01
    • 2011-12-17
    • 2011-12-29
    相关资源
    最近更新 更多