public async Task TestSftpFileCopy() { var credentialsManager = new CredentialsManager { StorageSubfolder = "credentials\\test" }; string destPath = ConfigSettings["TestSSHPath"]; var storedCred = await credentialsManager.GetUnlockedCredentialsDictionary(ConfigSettings["TestCredentialsKey_SSH"]); // var credentials = new UserCredentials(storedCred["username"], storedCred["password"]); // create a test temp file var tmpPath = Path.GetTempFileName(); File.WriteAllText(tmpPath, "This is a test temp file"); var files = new List <FileCopy> { new FileCopy { SourcePath = tmpPath, DestinationPath = destPath + "/testfilecopy.txt" } }; var client = new SftpClient(new SshConnectionConfig { Host = ConfigSettings["TestSSHHost"], KeyPassphrase = storedCred["password"], Port = 22, Username = storedCred["username"], PrivateKeyPath = ConfigSettings["TestSSHPrivateKeyPath"] }); // test file list var fileList = client.ListFiles(destPath, null); Assert.IsTrue(fileList.Count > 0); // test file copy var copiedOK = client.CopyLocalToRemote(files, null); Assert.IsTrue(copiedOK); File.Delete(tmpPath); }