8.2.34 | Linux | www-data (uid:33)
👁 View: ssh.py
📁 /snap/google-cloud-cli/current/lib/surface/workstations/ssh.py
# -*- coding: utf-8 -*- # # Copyright 2023 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Command for SSHing into a started workstation.""" import threading from googlecloudsdk.api_lib.workstations import workstations from googlecloudsdk.calliope import base from googlecloudsdk.command_lib.workstations import flags as workstations_flags @base.RegionalEndpointsSupported @base.ReleaseTracks( base.ReleaseTrack.GA, base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA ) @base.DefaultUniverseOnly class Start(base.Command): """SSH into a running workstation. SSH into a running workstation. Note that arguments for the `NO_PROXY` environment variable must be FQDNs. ## EXAMPLES To ssh into a running workstation, run: $ {command} WORKSTATION To specify the workstation port, run: $ {command} WORKSTATION --port=22 To ssh into a running workstation with a username, run: $ {command} WORKSTATION --user=my-user To run a command on the workstation, such as getting a snapshot of the guest's process tree, run: $ {command} WORKSTATION --command="ps -ejH" """ @staticmethod def Args(parser): workstations_flags.AddWorkstationResourceArg(parser) workstations_flags.AddPortField(parser) workstations_flags.AddLocalHostPortField(parser) workstations_flags.AddStartWorkstationFlag(parser) workstations_flags.AddCommandField(parser) workstations_flags.AddSshArgsAndUserField(parser) def Collection(self): return 'workstations.projects.locations.workstationClusters.workstationConfigs.workstations' def Run(self, args): # Format arguments for StartTcpTunnel args.workstation_port = args.port # Validate args in the main thread to reduce the chances of raising an # exception within the tunnel thread. Otherwise, the exception won't bubble # up correctly and can hang the process or generate unexpected output. location = args.CONCEPTS.workstation.Parse().locationsId client = workstations.Workstations(self.ReleaseTrack(), location=location) client.threading_event.clear() client.tcp_tunnel_open = False t = threading.Thread(target=client.StartTcpTunnel, args=(args, True)) t.daemon = True t.start() client.threading_event.wait() if client.tcp_tunnel_open: client.Ssh(args)
← Back
💻 Terminal
📤 Upload
📂
Click or Drag & Drop
📁 /snap/google-cloud-cli/current/lib/surface/workstations
NameSizePermModifiedActions
📁 __pycache__/-07752026-09-29 12:17🗑 Delete
📁 clusters/-07752026-09-29 12:17🗑 Delete
📁 configs/-07752026-09-29 12:17🗑 Delete
__init__.py1001B06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
create.yaml1.7K06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
delete.yaml757B06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
describe.yaml722B06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
get_iam_policy.yaml1K06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
list.yaml1K06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
list_usable.py2.1K06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
list_usable.yaml91B06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
set_iam_policy.yaml1000B06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
ssh.py2.8K06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
ssh.yaml92B06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
start.py1.7K06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
start.yaml92B06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
start_tcp_tunnel.py1.9K06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
start_tcp_tunnel.yaml92B06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
stop.py1.6K06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
stop.yaml92B06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
suspend.py1.7K06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
update.py1.8K06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
update.yaml92B06441980-01-01 08:00👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del