我只想使用新版Windows Terminal应用程序中的个人配置文件来SSH进入我的计算实例。
我只想使用新版Windows Terminal应用程序中的个人配置文件来SSH进入我的计算实例。
最简单、整洁的方法是使用运行于Linux WSL 2上的Ubuntu,安装 gcloud
SDK,然后通过运行gcloud init
设置gcloud,并在Windows Terminal中使用下面的配置:
{
"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。"commandline": "cmd.exe /k \"C:/Users/**YOUR_USER**/AppData/Local/Google/Cloud SDK/cloud_env.bat\""
。 {
"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"
}
没事了,我发现你可以在配置文件的部分添加命令行参数。对于任何其他试图弄清楚这一点的人:
{
"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()
{
"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"
},