Skip to content

Commit b3120bb

Browse files
committed
test ssh connection in rjm_config; change default remote dir location
1 parent 35911d4 commit b3120bb

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/rjm/setup/nesi.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from globus_sdk.scopes import TransferScopes
1515

1616
from rjm import utils
17+
from rjm.runners.paramiko_ssh_runner import ParamikoSSHRunner
1718

1819

1920
logger = logging.getLogger(__name__)
@@ -319,7 +320,7 @@ def setup_paramiko(self):
319320
# -----------------------------------------------------------------
320321
# 2️⃣ Ask for the remote base path (default under /tmp)
321322
# -----------------------------------------------------------------
322-
default_path = f"/tmp/{self._username}/rjm"
323+
default_path = f"/home/{self._username}/.cache/rjm"
323324
remote_base = input(
324325
f"Enter remote base path for Paramiko (default [{default_path}]): "
325326
).strip() or default_path
@@ -354,13 +355,27 @@ def setup_paramiko(self):
354355
print("-" * 80)
355356
print(pub_key_contents)
356357
print("-" * 80)
358+
print("Note: the key only needs to be copied once - if you")
359+
print("are reusing an existing key and have already copied")
360+
print("it across previously, you don't need to copy it again.")
361+
print("-" * 80)
357362
print("After you have added the key, press ENTER to continue.")
358363
print("=" * 80 + "\n")
359364
# Wait for user confirmation
360365
input("Press ENTER when the public key has been added to the remote authorized_keys file...")
361366

362-
# TODO: confirm ssh access to remote_addr using paramiko runner and created private key file
363-
# TODO: confirm write access to remote_base_path (or create remote_base_path if it doesn't exist)
367+
# -----------------------------------------------------------------
368+
# Test access and make sure the remote base path directory exists
369+
# -----------------------------------------------------------------
370+
print()
371+
print("Opening connection to the remote machine...")
372+
runner = ParamikoSSHRunner()
373+
runner.setup()
374+
print(f"Creating remote directory if needed ({self._remote_base_path})...")
375+
runner.run_command(f"mkdir -p {self._remote_base_path}")
376+
print(f"Testing write access to remote directory...")
377+
runner.run_command(f"test -d {self._remote_base_path} && test -w {self._remote_base_path}")
378+
print("Finished test")
364379

365380
# --------------------------------------------------------------------- #
366381
# Helper to expose Paramiko configuration

0 commit comments

Comments
 (0)