Reputation: 129
I just want to SSH into my compute instances using a profile in the new Windows Terminal app.
Upvotes: 9
Views: 10976
Reputation: 2374
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)
Upvotes: 7
Reputation: 31
You can try this, work for me: First at all, add "C:\Program Files (x86)\Google\Cloud SDK" to windows path, then add to Windows Terminal JSON file this:
For cmd:
{
"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"
},
For 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"
},
Upvotes: 0
Reputation:
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"
}
Upvotes: 2
Reputation: 61
This worked for me:
"commandline": "cmd.exe /k \"C:/Users/**YOUR_USER**/AppData/Local/Google/Cloud SDK/cloud_env.bat\""
.
Remember about escaping backslash.
Upvotes: 6
Reputation: 129
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()
Upvotes: 2