Skip to content

Commit 99f5599

Browse files
Try ssh if PAT/2FA not configured
1 parent 98afcc4 commit 99f5599

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/sagemaker/git_utils.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,15 @@ def _run_clone_command(repo_url, dest_dir):
278278
my_env["GIT_TERMINAL_PROMPT"] = "0"
279279
subprocess.check_call(["git", "clone", repo_url, dest_dir], env=my_env)
280280
elif repo_url.startswith("git@") or repo_url.startswith("ssh://"):
281-
with tempfile.NamedTemporaryFile() as sshnoprompt:
282-
with open(sshnoprompt.name, "w") as write_pipe:
283-
write_pipe.write("ssh -oBatchMode=yes $@")
284-
os.chmod(sshnoprompt.name, 0o511)
285-
my_env["GIT_SSH"] = sshnoprompt.name
281+
try:
282+
with tempfile.NamedTemporaryFile() as sshnoprompt:
283+
with open(sshnoprompt.name, "w") as write_pipe:
284+
write_pipe.write("ssh -oBatchMode=yes $@")
285+
os.chmod(sshnoprompt.name, 0o511)
286+
my_env["GIT_SSH"] = sshnoprompt.name
287+
subprocess.check_call(["git", "clone", repo_url, dest_dir], env=my_env)
288+
except subprocess.CalledProcessError:
289+
del my_env["GIT_SSH"]
286290
subprocess.check_call(["git", "clone", repo_url, dest_dir], env=my_env)
287291

288292

0 commit comments

Comments
 (0)