|
14 | 14 | from globus_sdk.scopes import TransferScopes |
15 | 15 |
|
16 | 16 | from rjm import utils |
| 17 | +from rjm.runners.paramiko_ssh_runner import ParamikoSSHRunner |
17 | 18 |
|
18 | 19 |
|
19 | 20 | logger = logging.getLogger(__name__) |
@@ -319,7 +320,7 @@ def setup_paramiko(self): |
319 | 320 | # ----------------------------------------------------------------- |
320 | 321 | # 2️⃣ Ask for the remote base path (default under /tmp) |
321 | 322 | # ----------------------------------------------------------------- |
322 | | - default_path = f"/tmp/{self._username}/rjm" |
| 323 | + default_path = f"/home/{self._username}/.cache/rjm" |
323 | 324 | remote_base = input( |
324 | 325 | f"Enter remote base path for Paramiko (default [{default_path}]): " |
325 | 326 | ).strip() or default_path |
@@ -354,13 +355,27 @@ def setup_paramiko(self): |
354 | 355 | print("-" * 80) |
355 | 356 | print(pub_key_contents) |
356 | 357 | 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) |
357 | 362 | print("After you have added the key, press ENTER to continue.") |
358 | 363 | print("=" * 80 + "\n") |
359 | 364 | # Wait for user confirmation |
360 | 365 | input("Press ENTER when the public key has been added to the remote authorized_keys file...") |
361 | 366 |
|
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") |
364 | 379 |
|
365 | 380 | # --------------------------------------------------------------------- # |
366 | 381 | # Helper to expose Paramiko configuration |
|
0 commit comments