|
28 | 28 | TopLevelFolder, |
29 | 29 | ) |
30 | 30 |
|
31 | | -import paramiko |
32 | 31 | import yaml |
33 | 32 |
|
34 | 33 | from datashuttle.configs import ( |
@@ -820,46 +819,26 @@ def setup_ssh_connection(self) -> None: |
820 | 819 | "setup-ssh-connection-to-central-server", local_vars=locals() |
821 | 820 | ) |
822 | 821 |
|
823 | | - verified = ssh.verify_ssh_central_host( |
| 822 | + verified = ssh.verify_ssh_central_host_api( |
824 | 823 | self.cfg["central_host_id"], |
825 | 824 | self.cfg.hostkeys_path, |
826 | 825 | log=True, |
827 | 826 | ) |
828 | 827 |
|
829 | 828 | if verified: |
830 | | - ssh.setup_ssh_key(self.cfg, log=True) |
831 | | - self._setup_rclone_central_ssh_config(log=True) |
| 829 | + private_key_str = ssh.setup_ssh_key_api(self.cfg, log=True) |
| 830 | + |
| 831 | + self._setup_rclone_central_ssh_config(private_key_str, log=True) |
832 | 832 |
|
833 | 833 | rclone.check_successful_connection_and_raise_error_on_fail( |
834 | 834 | self.cfg |
835 | 835 | ) |
836 | 836 |
|
837 | | - ds_logger.close_log_filehandler() |
838 | | - |
839 | | - @requires_ssh_configs |
840 | | - @check_is_not_local_project |
841 | | - def write_public_key(self, filepath: str) -> None: |
842 | | - """Save the public SSH key to a specified filepath. |
843 | | -
|
844 | | - By default, only the SSH private key is stored in the |
845 | | - datashuttle configs folder. Use this function to save |
846 | | - the public key. |
847 | | -
|
848 | | - Parameters |
849 | | - ---------- |
850 | | - filepath |
851 | | - Full filepath (including filename) to write the |
852 | | - public key to. |
853 | | -
|
854 | | - """ |
855 | | - key: paramiko.RSAKey |
856 | | - key = paramiko.RSAKey.from_private_key_file( |
857 | | - self.cfg.ssh_key_path.as_posix() |
858 | | - ) |
| 837 | + utils.log_and_message( |
| 838 | + "SSH key pair setup successfully. SSH key saved to the RClone config file." |
| 839 | + ) |
859 | 840 |
|
860 | | - with open(filepath, "w") as public: |
861 | | - public.write(key.get_base64()) |
862 | | - public.close() |
| 841 | + ds_logger.close_log_filehandler() |
863 | 842 |
|
864 | 843 | # ------------------------------------------------------------------------- |
865 | 844 | # Google Drive |
@@ -1588,11 +1567,13 @@ def _make_project_metadata_if_does_not_exist(self) -> None: |
1588 | 1567 | """ |
1589 | 1568 | folders.create_folders(self.cfg.project_metadata_path, log=False) |
1590 | 1569 |
|
1591 | | - def _setup_rclone_central_ssh_config(self, log: bool) -> None: |
| 1570 | + def _setup_rclone_central_ssh_config( |
| 1571 | + self, private_key_str: str, log: bool |
| 1572 | + ) -> None: |
1592 | 1573 | rclone.setup_rclone_config_for_ssh( |
1593 | 1574 | self.cfg, |
1594 | 1575 | self.cfg.get_rclone_config_name("ssh"), |
1595 | | - self.cfg.ssh_key_path, |
| 1576 | + private_key_str, |
1596 | 1577 | log=log, |
1597 | 1578 | ) |
1598 | 1579 |
|
|
0 commit comments