diff --git a/src/aiida/transports/plugins/ssh.py b/src/aiida/transports/plugins/ssh.py index b15850d75c..773c1f51fc 100644 --- a/src/aiida/transports/plugins/ssh.py +++ b/src/aiida/transports/plugins/ssh.py @@ -1167,9 +1167,6 @@ def copy(self, remotesource, remotedestination, dereference=False, recursive=Tru self._exec_cp(cp_exe, cp_flags, file, remotedestination) else: - if not self.path_exists(remotesource): - raise FileNotFoundError('Source not found') - self._exec_cp(cp_exe, cp_flags, remotesource, remotedestination) def _exec_cp(self, cp_exe, cp_flags, src, dst): @@ -1188,6 +1185,9 @@ def _exec_cp(self, cp_exe, cp_flags, src, dst): retval, stdout, stderr, command ) ) + if 'No such file or directory' in str(stderr): + raise FileNotFoundError(f'Error while executing cp: {stderr}') + raise OSError( 'Error while executing cp. Exit code: {}, ' "stdout: '{}', stderr: '{}', " "command: '{}'".format( retval, stdout, stderr, command