public void DownloadFile(ResourceNode node, string remotePath, string localPath) { if (_sftpClient != null) { using (var stream = File.OpenWrite(localPath)) { _sftpClient.DownloadFile(remotePath, stream); } //scp = _scpPool.GetSshSession(true, node); //scp.Recursive = recursive; //scp.Download(remotePath, new FileInfo(localPath)); } else if (_scp != null) { _scp.Get(remotePath, localPath); } else { throw new Exception("No connection established to node for copy"); } }
private void ScpGet(ResourceNode node, string remotePath, string localPath) { var scp = new Ssh.Scp(node.NodeAddress, node.Credentials.Username, node.Credentials.Password); scp.Connect(); scp.Recursive = true; scp.Get(remotePath, localPath); scp.Close(); }
public static bool DownloadScp(string server, string remoteFileName, string localFileName, string username, string password) { try { SshTransferProtocolBase sshCp = new Scp(server, username, password); sshCp.Connect(); sshCp.Get(remoteFileName, localFileName); sshCp.Close(); return true; } catch (Exception e) { nlogger.ErrorException("while downloading this happened", e); return false; } }