Skip to content

Commit 2610027

Browse files
committed
enable remote ssh connection
1 parent e1581b0 commit 2610027

File tree

9 files changed

+1273
-21
lines changed

9 files changed

+1273
-21
lines changed

src/snowflake/cli/_plugins/remote/commands.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ def start(
6969
"--image",
7070
help="Custom image to use (can be full path like 'repo/image:tag' or just tag like '1.7.1')",
7171
),
72+
ssh: bool = typer.Option(
73+
False,
74+
"--ssh",
75+
help="Set up SSH configuration for connecting to the remote environment. This is a blocking command that keeps SSH connections alive.",
76+
),
77+
no_ssh_key: bool = typer.Option(
78+
False,
79+
"--no-ssh-key",
80+
help="When used with --ssh, skip SSH key generation and use token-only authentication (less secure)",
81+
),
7282
**options,
7383
) -> None:
7484
"""
@@ -83,9 +93,16 @@ def start(
8393
- Resume existing service: snow remote start myproject
8494
- Create new service: snow remote start --compute-pool my_pool
8595
- Create named service: snow remote start myproject --compute-pool my_pool
96+
- Start with SSH setup: snow remote start myproject --ssh
97+
- Start with SSH (no key): snow remote start myproject --ssh --no-ssh-key
8698
8799
The --compute-pool parameter is only required when creating a new service. For resuming
88100
existing services, the compute pool is not needed.
101+
102+
SSH Options:
103+
- Use --ssh to set up SSH configuration for secure terminal access
104+
- Use --no-ssh-key with --ssh for token-only authentication (less secure)
105+
- SSH setup is a blocking command that continuously refreshes authentication tokens
89106
"""
90107
try:
91108
manager = RemoteManager()
@@ -96,6 +113,9 @@ def start(
96113
external_access=eai_name,
97114
stage=stage,
98115
image=image,
116+
generate_ssh_key=(
117+
ssh and not no_ssh_key
118+
), # Only generate SSH key if --ssh and not --no-ssh-key
99119
)
100120

101121
# Display appropriate success message based on what happened
@@ -132,6 +152,10 @@ def start(
132152
if image:
133153
log.debug("Using custom image: %s", image)
134154

155+
# Handle SSH setup if requested - this is a blocking operation
156+
if ssh:
157+
manager.setup_ssh_connection(service_name)
158+
135159
except ValueError as e:
136160
cc.warning(f"Error: {e}")
137161
raise typer.Exit(code=1)

src/snowflake/cli/_plugins/remote/constants.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ComputeResources:
4747
ENABLE_REMOTE_DEV_ENV_VAR = "IS_REMOTE_DEV"
4848
MEMORY_VOLUME_NAME = "dshm"
4949
USER_WORKSPACE_VOLUME_NAME = "user-workspace"
50-
USER_WORKSPACE_VOLUME_MOUNT_PATH = "/root/workspace"
50+
USER_WORKSPACE_VOLUME_MOUNT_PATH = "/root/user-default"
5151
USER_VSCODE_DATA_VOLUME_NAME = "user-vscode-data"
5252
USER_VSCODE_DATA_VOLUME_MOUNT_PATH = "/root/.vscode-server"
5353

@@ -84,7 +84,7 @@ class ServiceResult(enum.Enum):
8484
DEFAULT_IMAGE_REPO = "/snowflake/images/snowflake_images"
8585
DEFAULT_IMAGE_CPU = "st_plat/runtime/x86/runtime_image/snowbooks"
8686
DEFAULT_IMAGE_GPU = "st_plat/runtime/x86/generic_gpu/runtime_image/snowbooks"
87-
DEFAULT_IMAGE_TAG = "1.7.1"
87+
DEFAULT_IMAGE_TAG = "1.7.2"
8888

8989
# Percent of container memory to allocate for /dev/shm volume
9090
MEMORY_VOLUME_SIZE = 0.3
@@ -98,6 +98,16 @@ class ServiceResult(enum.Enum):
9898
WEBSOCKET_SSH_ENDPOINT_NAME = "websocket-ssh"
9999
RAY_DASHBOARD_ENDPOINT_NAME = "ray-dashboard"
100100

101+
# SSH Configuration
102+
DEFAULT_SSH_REFRESH_INTERVAL = 300 # 5 minutes
103+
SSH_RETRY_INTERVAL = 30 # 30 seconds
104+
SSH_COUNTDOWN_INTERVAL = 30 # Show countdown every 30 seconds
105+
SSH_DIR_NAME = ".ssh"
106+
SSH_KEY_SUBDIR_NAME = "snowflake-remote"
107+
SSH_CONFIG_FILENAME = "config"
108+
SSH_DEFAULT_PORT = 22
109+
SSH_DEFAULT_USER = "root"
110+
101111
# ML runtime health check settings
102112
ML_RUNTIME_HEALTH_CHECK_PORT = "5001"
103113
ENABLE_HEALTH_CHECKS = "false"

0 commit comments

Comments
 (0)