I just want to SSH into my compute instances using a profile in the new Windows Terminal app.
Asked
Active
Viewed 2,343 times
4 Answers
3
This worked for me:
"commandline": "cmd.exe /k \"C:/Users/**YOUR_USER**/AppData/Local/Google/Cloud SDK/cloud_env.bat\""
.
Remember about escaping backslash.
Lukasz Pojezierski
- 31
- 2
2
Nvm, I found out you can add a commandline argument to the profiles section. For anybody else trying to figure this out:
{
"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
}
You can generate a guid in PowerShell using this command:
[guid]::NewGuid()
Shivang P Swain
- 81
- 6
-
1That assumes that SSH is already authenticated. But my default Google Shell is at C:\WINDOWS\system32\cmd.exe /k ""C:\Program Files (x86)\Google\Cloud SDK\cloud_env.bat"" But I cannot seem to set up that Batch file in Windows Terminal It comes up with C:\program not recognised. – user2129049 Aug 30 '20 at 13:16
-
@user2129049 I must say just set up SSH regularly before going about this and setting it up as a profile in the terminal. The other problem you seem to be facing stems from the fact there are spaces in the path you are providing and unless such a path is "covered in double quotes", the path is only read up to the first space. And so, C:\Program is what the path has become. Use double quotes and that'll solve that problem. – Shivang P Swain Aug 31 '20 at 05:03
-
1I end up using the Visual Studio example, which is also under programs File. So "commandline": "cmd.exe /k "C:/Program Files (x86)/Google/Cloud SDK/cloud_env.bat"", "icon": "C:\Program Files (x86)\Google\Cloud SDK\cloud_platform_logo.ico", Works for me in getting the Google SDK shell open under Terminal – user2129049 Sep 01 '20 at 11:17
2
Easiest and neat way to do this by running Linux WSL 2 like Ubuntu, install gcloud
sdk, then setup gcloud by running gcloud init
and use below config in 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",
}
Note: In the command:
wsl -d WSL-NAME gcloud beta cloud-shell ssh
, you can use any wsl like (kali-linux, alpine, openSUSE-Leap-15.2, etc. just make sure you install and setup gcloud sdk)
Sanjay Rawat
- 2,045
- 10
- 28
1
It worked for me:
{
"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"
}
Eugene Kopich
- 383
- 3
- 7