Skip to content

Commit 07ba98b

Browse files
Add extra ssh options for sm-local-ssh-ide
1 parent 1f5e5f0 commit 07ba98b

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

sagemaker_ssh_helper/sm-local-ssh-ide

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
11
#!/bin/bash
22

33
# Commands:
4-
# connect <kernel_gateway_name> [--ssh-only]
4+
# connect <kernel_gateway_name> [--ssh-only] [<extra_ssh_args>]
55
# run-command <command> <args...>
6+
# TODO: create <kernel_gateway_name> [--force-recreate] --domain <domain> --profile <profile> --image datascience-1.0 --instance ml.t3.medium (use local user id)
7+
# TODO: list
8+
# TODO: open-firefox, open-chrome, open-safari
9+
# TODO: set-kernel-gateway-name, get-kernel-gateway-name
610

711
# SageMaker Studio Kernel Gateway name is usually the same as the hostname,
812
# e. g. sagemaker-data-science-ml-m5-large-1234567890abcdef0
913

14+
# To open SageMaker Studio UI in Firefox from command line on macOS, use the following command:
15+
# open -a Firefox $(AWS_PROFILE=terry aws sagemaker create-presigned-domain-url --domain-id d-lnwlaexample --user-profile-name terry-whitlock --query AuthorizedUrl --output text)
16+
1017
COMMAND=$1
1118

1219
if [[ "$COMMAND" == "connect" ]]; then
1320

1421
SM_STUDIO_KGW_NAME="$2"
1522
OPTIONS="$3"
1623

24+
# FIXME: distinguish between user profiles
25+
1726
INSTANCE_ID=$(python <<EOF
1827
import sagemaker; from sagemaker_ssh_helper.manager import SSMManager;
1928
import logging; logging.basicConfig(level=logging.INFO);
2029
print(SSMManager().get_studio_kgw_instance_ids("$SM_STUDIO_KGW_NAME", timeout_in_sec=300)[0])
2130
EOF
2231
)
2332

33+
# TODO: set-jb-license-server
34+
# TODO: check that it's not started with 'http'
2435
# replace with your JetBrains License Server host, or leave it as is if you don't use one
2536
JB_LICENSE_SERVER_HOST="jetbrains-license-server.example.com"
2637

@@ -34,14 +45,21 @@ EOF
3445

3546

3647
if [[ "$OPTIONS" == "--ssh-only" ]]; then
48+
shift
49+
shift
50+
shift
3751
sm-local-start-ssh "$INSTANCE_ID" \
38-
-L localhost:10022:localhost:22
52+
-L localhost:10022:localhost:22 \
53+
$*
3954
else
55+
shift
56+
shift
4057
sm-local-start-ssh "$INSTANCE_ID" \
4158
-L localhost:10022:localhost:22 \
4259
-L localhost:5901:localhost:5901 \
4360
-L localhost:8889:localhost:8889 \
44-
-R 127.0.0.1:443:"$JB_LICENSE_SERVER_HOST":443
61+
-R 127.0.0.1:443:"$JB_LICENSE_SERVER_HOST":443 \
62+
$*
4563
fi
4664

4765

@@ -51,7 +69,7 @@ elif [[ "$COMMAND" == "run-command" ]]; then
5169
ARGS=$*
5270

5371
# shellcheck disable=SC2086
54-
ssh -i ~/.ssh/sagemaker-ssh-gw -p 10022 root@localhost \
72+
ssh -4 -i ~/.ssh/sagemaker-ssh-gw -p 10022 root@localhost \
5573
-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
5674
$ARGS
5775

0 commit comments

Comments
 (0)