5

我只想使用新的 Windows 终端应用程序中的配置文件通过 SSH 连接到我的计算实例。

4

5 回答 5

6

这对我有用: "commandline": "cmd.exe /k \"C:/Users/**YOUR_USER**/AppData/Local/Google/Cloud SDK/cloud_env.bat\""

记住转义反斜杠。

于 2020-09-11T16:50:40.660 回答
4

通过像 Ubuntu 一样运行 Linux WSL 2,安装sdk,然后通过在 Windows 终端中gcloud运行和使用以下配置来设置 gcloud 是最简单和简洁的方法:gcloud init

{
  "guid": "{d8567bf5-f802-498a-899a-efedc99a2aa8}",
  "hidden": false,
  "name": "Google Cloud Shell",
  "commandline": "wsl -d Ubuntu-20.04 gcloud beta cloud-shell ssh",
  "fontFace": "Cascadia Code PL",
  "useAcrylic": true,
  "acrylicOpacity": 0.6,
  "backgroundImage": "C:\\Users\\USERNAME\\.terminal\\.gshell-icon.png",
  "icon": "C:\\Users\\USERNAME\\.terminal\\.gcloud-icon.png",
  "backgroundImageStretchMode": "none",
  "backgroundImageAlignment": "center",
  "backgroundImageOpacity": 0.5,
  "tabColor": "#1a73e8",
}    

注意:在命令中:

wsl -d WSL-NAME gcloud beta cloud-shell ssh,您可以使用任何 wsl,例如(kali-linux、alpine、openSUSE-Leap-15.2 等。只要确保您安装并设置了 gcloud sdk)

于 2020-12-30T10:52:12.567 回答
3

Nvm,我发现您可以在配置文件部分添加命令行参数。对于其他试图弄清楚这一点的人:

{
       "guid": "{*add_a_guid*}",
       "name": "Google Cloud Shell",
       "commandline": "ssh -i *path_to_ssh_key* *username*@*ip_address*",
       "icon": "C:\\Program Files (x86)\\Google\\Cloud SDK\\cloud_platform_logo.ico",
       "hidden": false
}

您可以使用以下命令在 PowerShell 中生成 guid:

[guid]::NewGuid()
于 2020-07-17T07:57:02.580 回答
1

它对我有用:

  {
    "guid": "{c79dfc7a-3346-4dd3-b6c0-c0107e319a95}",
    "hidden": false,
    "name": "Google Cloud",
    "commandline": "powershell.exe -NoExit -ExecutionPolicy Bypass -File \"%USERPROFILE%\\AppData\\Local\\Google\\Cloud SDK\\google-cloud-sdk\\platform\\PowerShell\\GoogleCloud\\BootstrapCloudToolsForPowerShell.ps1\"",
    "icon": "%USERPROFILE%\\AppData\\Local\\Google\\Cloud SDK\\cloud_platform_logo.ico"
  }
于 2021-02-02T03:51:34.483 回答
0

你可以试试这个,为我工作:首先,将“C:\Program Files (x86)\Google\Cloud SDK”添加到 Windows 路径,然后添加到 Windows 终端 JSON 文件:

对于命令:

{
        "guid": "{9f8bb872-db3d-4398-9571-a983a22ff18e}",
        "hidden": false,
        "icon": "C:/Program Files (x86)/Google/Cloud SDK/supercloud-16x16.ico",
        "name": "Google Cloud SDK Shell",
        "startingDirectory": "C:/Program Files (x86)/Google/Cloud SDK",
        "commandline": "cmd.exe /k cloud_env.bat"
    },

对于 powershell:

{
        "guid": "{9f8bb872-db3d-4398-9571-a983a22ff18e}",
        "hidden": false,
        "icon": "C:/Program Files (x86)/Google/Cloud SDK/supercloud-16x16.ico",
        "name": "Google Cloud SDK Shell",
        "startingDirectory": "C:/Program Files (x86)/Google/Cloud SDK",
        "commandline": "powershell.exe -NoExit -ExecutionPolicy Bypass C:/cloud_env.bat"
    },
于 2022-02-05T18:18:24.803 回答