def scpPut(self, localFile, host, remoteFile, user=None): """ copy a file to remote host . similar as 'scp localfile host:remotefile' :param str localFile: path of local File. absolute or relative (depending where you are) :param str host: the IP address of the remote host where to copy :param str remoteFile: path of remote file (absolute) or in homedir if relative :param str user: login. user=None means 'root' :return: False if localFile does not exist, else True :rtype: bool NB : At least one getClient() must have been executed before calling this proc i.e. connection is already stored in self._connections >>> sshMngr.scpPut('/tmp/tototo', LX4SI3, '/tmp/tototo', user='******') """ userSsh = 'root' if user is None else user client = self.getClient(host, user=userSsh) scpClient = SCPClient(client.get_transport()) scpClient.socket_timeout = 1000.0 if os.path.isfile(localFile): LOGGER.trace("scpClient.put(%s, %s) to %s@%s", localFile, remoteFile, userSsh, host) scpClient.put(localFile, remoteFile) return True else: return False